Eliminate "conservancy" and "apps" subdirectories
The directory nesting is unnecessary here and confusing to navigate. I've moved all apps to the project subdirectory, currently called "www", but soon to be renamed "conservancy". I've also moved manage.py to the top-level directory.
This commit is contained in:
parent
cc3224bb60
commit
531a97a3c9
526 changed files with 76 additions and 109 deletions
19
manage.py
Executable file
19
manage.py
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
"""Django command-line utility for administration tasks.
|
||||
|
||||
See https://docs.djangoproject.com/en/4.0/ref/django-admin/
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'www.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class AssignmentConfig(AppConfig):
|
||||
name = 'conservancy.apps.assignment'
|
||||
name = 'www.assignment'
|
|
@ -3,7 +3,7 @@ from datetime import datetime, timedelta
|
|||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
from ... import bsoup
|
||||
from .. import bsoup
|
||||
from ..staff.models import Person
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
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
|
|
@ -1,5 +1,5 @@
|
|||
from django.conf.urls import include, patterns, url
|
||||
|
||||
urlpatterns = patterns('conservancy.apps.contacts.views',
|
||||
urlpatterns = patterns('www.contacts.views',
|
||||
(r'^/?$', 'subscribe'),
|
||||
)
|
|
@ -14,12 +14,12 @@ info_dict = {
|
|||
# make_object_list=True)),
|
||||
# )
|
||||
|
||||
# urlpatterns += patterns('conservancy.apps.events.views',
|
||||
# urlpatterns += patterns('www.events.views',
|
||||
# (r'^/?$', 'custom_index', dict(info_dict, queryset=Event.past.all(), paginate_by=10)),
|
||||
# (r'^(?P<year>\d{4})/(?P<slug>[-\w]+)/$', 'event_detail', dict(info_dict, slug_field='slug')),
|
||||
# (r'^ics/$', 'future_event_ics', info_dict),
|
||||
# )
|
||||
|
||||
urlpatterns = patterns('conservancy.apps.events.views',
|
||||
urlpatterns = patterns('www.events.views',
|
||||
(r'^.*$', 'custom_index', dict(info_dict, queryset=Event.past.all(), paginate_by=10)),
|
||||
)
|
|
@ -8,8 +8,8 @@ from django.contrib.syndication.views import Feed
|
|||
from django.shortcuts import render
|
||||
from django.utils.feedgenerator import Rss201rev2Feed
|
||||
|
||||
from .apps.blog.models import Entry as BlogEntry
|
||||
from .apps.news.models import PressRelease
|
||||
from .blog.models import Entry as BlogEntry
|
||||
from .news.models import PressRelease
|
||||
|
||||
|
||||
class ConservancyFeedBase(Feed):
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class FOSSYConfig(AppConfig):
|
||||
name = 'conservancy.apps.fossy'
|
||||
name = 'www.fossy'
|
|
@ -2,9 +2,9 @@ from datetime import datetime
|
|||
|
||||
from django.shortcuts import render
|
||||
|
||||
from .apps.blog.models import Entry
|
||||
from .apps.news.models import PressRelease
|
||||
from .apps.supporters.models import Supporter
|
||||
from .blog.models import Entry
|
||||
from .news.models import PressRelease
|
||||
from .supporters.models import Supporter
|
||||
|
||||
|
||||
def view(request):
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime as DateTime
|
||||
|
||||
from . import settings
|
||||
from .apps.fundgoal.models import FundraisingGoal
|
||||
from .fundgoal.models import FundraisingGoal
|
||||
|
||||
SITE_FUNDGOAL = 'cy2022-end-year-match'
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
www_path = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
if www_path not in sys.path:
|
||||
sys.path.append(www_path)
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conservancy.settings")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
|
@ -4,7 +4,7 @@ from django.conf import settings
|
|||
from django.contrib.sites.models import Site
|
||||
from django.db import models
|
||||
|
||||
from ... import bsoup
|
||||
from .. import bsoup
|
||||
from ..events.models import Event
|
||||
from ..staff.models import Person
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
from pathlib import Path
|
||||
|
||||
from djangocommonsettings import *
|
||||
from .djangocommonsettings import *
|
||||
|
||||
SITE_ID = 2
|
||||
ROOT_URLCONF = 'conservancy.urls'
|
||||
ROOT_URLCONF = 'www.urls'
|
||||
|
||||
FORCE_CANONICAL_HOSTNAME = False if DEBUG else 'sfconservancy.org'
|
||||
|
||||
|
@ -87,31 +87,31 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.humanize',
|
||||
'django.contrib.staticfiles',
|
||||
'conservancy.apps.blog',
|
||||
'conservancy.apps.contacts',
|
||||
'conservancy.apps.contractpatch',
|
||||
'conservancy.apps.events',
|
||||
'conservancy.apps.news',
|
||||
'conservancy.apps.staff',
|
||||
# 'conservancy.apps.summit_registration',
|
||||
'conservancy.apps.worldmap',
|
||||
'conservancy.apps.supporters',
|
||||
'conservancy.apps.fundgoal',
|
||||
'conservancy.apps.assignment',
|
||||
'conservancy.apps.fossy',
|
||||
'podjango',
|
||||
'usethesource.apps.UseTheSourceConfig',
|
||||
'www.blog',
|
||||
'www.contacts',
|
||||
'www.contractpatch',
|
||||
'www.events',
|
||||
'www.news',
|
||||
'www.staff',
|
||||
# 'www.summit_registration',
|
||||
'www.worldmap',
|
||||
'www.supporters',
|
||||
'www.fundgoal',
|
||||
'www.assignment',
|
||||
'www.fossy',
|
||||
'www.podjango',
|
||||
'www.usethesource.apps.UseTheSourceConfig',
|
||||
]
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [
|
||||
BASE_DIR / 'conservancy' / 'templates',
|
||||
BASE_DIR / 'conservancy' / 'static',
|
||||
BASE_DIR / 'templates',
|
||||
BASE_DIR / 'static',
|
||||
],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
|
@ -120,8 +120,8 @@ TEMPLATES = [
|
|||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'conservancy.local_context_processors.host_url',
|
||||
'conservancy.local_context_processors.sitefundraiser',
|
||||
'www.local_context_processors.host_url',
|
||||
'www.local_context_processors.sitefundraiser',
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ TEMPLATES = [
|
|||
|
||||
STATIC_ROOT = BASE_DIR.parent / 'collected_static'
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / 'conservancy' / 'static',
|
||||
BASE_DIR / 'static',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -137,6 +137,6 @@ MIDDLEWARE = [
|
|||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'conservancy.middleware.ForceCanonicalHostnameMiddleware',
|
||||
'www.middleware.ForceCanonicalHostnameMiddleware',
|
||||
# 'django.middleware.doc.XViewMiddleware',
|
||||
]
|
|
@ -2,7 +2,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
from django.shortcuts import render
|
||||
|
||||
from .apps.supporters.models import Supporter
|
||||
from .supporters.models import Supporter
|
||||
|
||||
|
||||
def view(request):
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue