From 8e40d45934a4c62853c176ddaed6a3a525a0921d Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Thu, 17 Jan 2019 21:32:22 +1100 Subject: [PATCH] Add basic membership DB framework --- selfserv/urls.py | 1 + ssmain/jinja2/ssmain/base.html | 1 + ssmain/jinja2/ssmain/splash.html | 10 +++++ ssmembership/__init__.py | 0 ssmembership/admin.py | 3 ++ ssmembership/apps.py | 5 +++ ssmembership/jinja2/ssmembership/index.html | 28 +++++++++++++ ssmembership/migrations/__init__.py | 0 ssmembership/models.py | 44 +++++++++++++++++++++ ssmembership/tests.py | 3 ++ ssmembership/urls.py | 23 +++++++++++ ssmembership/views.py | 30 ++++++++++++++ 12 files changed, 148 insertions(+) create mode 100644 ssmembership/__init__.py create mode 100644 ssmembership/admin.py create mode 100644 ssmembership/apps.py create mode 100644 ssmembership/jinja2/ssmembership/index.html create mode 100644 ssmembership/migrations/__init__.py create mode 100644 ssmembership/models.py create mode 100644 ssmembership/tests.py create mode 100644 ssmembership/urls.py create mode 100644 ssmembership/views.py diff --git a/selfserv/urls.py b/selfserv/urls.py index 8cf182e..22c08b8 100644 --- a/selfserv/urls.py +++ b/selfserv/urls.py @@ -24,5 +24,6 @@ urlpatterns = [ path('auth/', include('social_django.urls', namespace='social')), path('treasury/', include('sstreasury.urls')), path('promotions/', include('sspromotions.urls')), + path('membership/', include('ssmembership.urls')), path('', include('ssmain.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/ssmain/jinja2/ssmain/base.html b/ssmain/jinja2/ssmain/base.html index 86cd2ba..3158ea1 100644 --- a/ssmain/jinja2/ssmain/base.html +++ b/ssmain/jinja2/ssmain/base.html @@ -72,6 +72,7 @@ Society Self-Service {% if request.resolver_match.func.__module__.startswith('sstreasury.') %}Treasury{% endif %} {% if request.resolver_match.func.__module__.startswith('sspromotions.') %}Promotions{% endif %} + {% if request.resolver_match.func.__module__.startswith('ssmembership.') %}Membership{% endif %} + +
+
Membership Portal
+
View and update your membership details.
+
+
+ + Enter +
+
{% endblock %} diff --git a/ssmembership/__init__.py b/ssmembership/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ssmembership/admin.py b/ssmembership/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/ssmembership/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/ssmembership/apps.py b/ssmembership/apps.py new file mode 100644 index 0000000..3e5e85a --- /dev/null +++ b/ssmembership/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class SsmembershipConfig(AppConfig): + name = 'ssmembership' diff --git a/ssmembership/jinja2/ssmembership/index.html b/ssmembership/jinja2/ssmembership/index.html new file mode 100644 index 0000000..d7e8fd5 --- /dev/null +++ b/ssmembership/jinja2/ssmembership/index.html @@ -0,0 +1,28 @@ +{% extends 'ssmain/base.html' %} + +{# + Society Self-Service + Copyright © 2018-2019 Yingtong Li (RunasSudo) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +#} + +{% block content %} + {% if not member %} +

No membership records

+

This email address is not associated with a current membership.

+ {% else %} +

Membership details

+ {% endif %} +{% endblock %} diff --git a/ssmembership/migrations/__init__.py b/ssmembership/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ssmembership/models.py b/ssmembership/models.py new file mode 100644 index 0000000..8d79202 --- /dev/null +++ b/ssmembership/models.py @@ -0,0 +1,44 @@ +# Society Self-Service +# Copyright © 2018-2019 Yingtong Li (RunasSudo) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.db import models + +class Member(models.Model): + email = models.CharField(max_length=100) + + first_name = models.CharField(max_length=100) + last_name = models.CharField(max_length=100) + + student_id = models.CharField(max_length=8) + is_msa = models.BooleanField() + + year = models.IntegerField( + choices = ( + (0, 'Year A'), + (1, 'Year 1'), + (2, 'Year 2'), + (3, 'Year 3B'), + (4, 'Year 4C'), + (5, 'Year 5D'), + (97, 'BMedSc(Hons)'), + (98, 'PhD'), + (99, 'Intermission'), + ) + ) + + phone = models.CharField(max_length=20) + + expires = models.DateField() diff --git a/ssmembership/tests.py b/ssmembership/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/ssmembership/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/ssmembership/urls.py b/ssmembership/urls.py new file mode 100644 index 0000000..a19ff61 --- /dev/null +++ b/ssmembership/urls.py @@ -0,0 +1,23 @@ +# Society Self-Service +# Copyright © 2018-2019 Yingtong Li (RunasSudo) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='membership'), +] diff --git a/ssmembership/views.py b/ssmembership/views.py new file mode 100644 index 0000000..573f8bb --- /dev/null +++ b/ssmembership/views.py @@ -0,0 +1,30 @@ +# Society Self-Service +# Copyright © 2018-2019 Yingtong Li (RunasSudo) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from django.contrib.auth.decorators import login_required + +from django.shortcuts import render + +from . import models + +@login_required +def index(request): + try: + member = models.Member.objects.get(email=request.user.email) + except models.Member.DoesNotExist: + member = None + + return render(request, 'ssmembership/index.html', {'member': member})