Rename "www" directory to "conservancy"

This commit is contained in:
Ben Sturmfels 2023-10-20 18:45:46 +11:00
parent 531a97a3c9
commit ce6be591bd
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
584 changed files with 73 additions and 31 deletions

42
conservancy/__init__.py Normal file
View file

@ -0,0 +1,42 @@
import hashlib
from django.conf import settings
class ParameterValidator:
def __init__(self, given_hash_or_params, params_hash_key=None):
if params_hash_key is None:
self.given_hash = given_hash_or_params
else:
self.given_hash = given_hash_or_params.get(params_hash_key)
seed = getattr(settings, 'CONSERVANCY_SECRET_KEY', '').encode('utf-8')
self.hasher = hashlib.sha256(seed)
if isinstance(self.given_hash, str):
self.hash_type = type(self.given_hash)
else:
self.hash_type = type(self.hasher.hexdigest())
self.valid = None
if not (self.given_hash and seed):
self.fail()
def __enter__(self):
self.valid = self.valid and None
return self
def __exit__(self, exc_type, exc_value, exc_tb):
if exc_type is None:
self.check()
else:
self.fail()
def validate(self, data):
self.valid = self.valid and None
self.hasher.update(data)
def check(self):
if self.valid or (self.valid is None):
self.valid = self.hash_type(self.hasher.hexdigest()) == self.given_hash
return self.valid
def fail(self):
self.valid = False

View file

@ -2,4 +2,4 @@ from django.apps import AppConfig
class AssignmentConfig(AppConfig):
name = 'www.assignment'
name = 'conservancy.assignment'

View file

@ -2,4 +2,4 @@ from django.apps import AppConfig
class FOSSYConfig(AppConfig):
name = 'www.fossy'
name = 'conservancy.fossy'

View file

Before

Width:  |  Height:  |  Size: 631 B

After

Width:  |  Height:  |  Size: 631 B

View file

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View file

Before

Width:  |  Height:  |  Size: 6 KiB

After

Width:  |  Height:  |  Size: 6 KiB

View file

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 661 B

View file

Before

Width:  |  Height:  |  Size: 643 B

After

Width:  |  Height:  |  Size: 643 B

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 689 B

Some files were not shown because too many files have changed in this diff Show more