From d77dcf62b4005a0f36ef2fa7ba6d3651d2ef38d7 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sat, 5 Nov 2022 14:17:27 -0600 Subject: Initial commit (users and statuses) --- core/__init__.py | 0 core/apps.py | 6 ++++++ core/config.py | 3 +++ core/context.py | 5 +++++ core/forms.py | 11 +++++++++++ core/views.py | 21 +++++++++++++++++++++ 6 files changed, 46 insertions(+) create mode 100644 core/__init__.py create mode 100644 core/apps.py create mode 100644 core/config.py create mode 100644 core/context.py create mode 100644 core/forms.py create mode 100644 core/views.py (limited to 'core') diff --git a/core/__init__.py b/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/core/apps.py b/core/apps.py new file mode 100644 index 0000000..c0ce093 --- /dev/null +++ b/core/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "core" diff --git a/core/config.py b/core/config.py new file mode 100644 index 0000000..0f09404 --- /dev/null +++ b/core/config.py @@ -0,0 +1,3 @@ +class Config: + + pass diff --git a/core/context.py b/core/context.py new file mode 100644 index 0000000..38a268c --- /dev/null +++ b/core/context.py @@ -0,0 +1,5 @@ +from django.conf import settings + + +def config_context(request): + return {"config": {"site_name": settings.SITE_NAME}} diff --git a/core/forms.py b/core/forms.py new file mode 100644 index 0000000..8a4801d --- /dev/null +++ b/core/forms.py @@ -0,0 +1,11 @@ +from crispy_forms.helper import FormHelper as BaseFormHelper +from crispy_forms.layout import Submit + + +class FormHelper(BaseFormHelper): + + submit_text = "Submit" + + def __init__(self, form=None, submit_text=None): + super().__init__(form) + self.add_input(Submit("submit", submit_text or "Submit")) diff --git a/core/views.py b/core/views.py new file mode 100644 index 0000000..dbaebf9 --- /dev/null +++ b/core/views.py @@ -0,0 +1,21 @@ +from django.views.generic import TemplateView + +from statuses.views.home import Home +from users.models import Identity + + +def homepage(request): + if request.user.is_authenticated: + return Home.as_view()(request) + else: + return LoggedOutHomepage.as_view()(request) + + +class LoggedOutHomepage(TemplateView): + + template_name = "index.html" + + def get_context_data(self): + return { + "identities": Identity.objects.filter(local=True), + } -- cgit v1.2.3