Add basic membership DB framework

This commit is contained in:
Yingtong Li 2019-01-17 21:32:22 +11:00
parent 37caf3bb9b
commit 8e40d45934
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
12 changed files with 148 additions and 0 deletions

View File

@ -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)

View File

@ -72,6 +72,7 @@
<a class="{% if request.resolver_match.func.__module__.startswith('ssmain.') %}active {% endif %}item" href="{{ url('index') }}">Society Self-Service</a>
{% if request.resolver_match.func.__module__.startswith('sstreasury.') %}<a class="{% if request.resolver_match.func.__module__.startswith('sstreasury.') %}active {% endif %}item" href="{{ url('treasury') }}">Treasury</a>{% endif %}
{% if request.resolver_match.func.__module__.startswith('sspromotions.') %}<a class="{% if request.resolver_match.func.__module__.startswith('sspromotions.') %}active {% endif %}item" href="{{ url('promotions') }}">Promotions</a>{% endif %}
{% if request.resolver_match.func.__module__.startswith('ssmembership.') %}<a class="{% if request.resolver_match.func.__module__.startswith('ssmembership.') %}active {% endif %}item" href="{{ url('membership') }}">Membership</a>{% endif %}
<div class="right menu">
{% if request.user.is_authenticated %}
<div class="item"><i class="user circle icon"></i>{{ request.user.first_name }} {{ request.user.last_name }}</div>

View File

@ -63,5 +63,15 @@
Enter
</div>
</a>
<a class="ui card" href="{{ url('membership') }}">
<div class="content">
<div class="header">Membership Portal</div>
<div class="description">View and update your membership details.</div>
</div>
<div class="ui bottom attached primary button">
<i class="chevron right icon" style="margin: 0 .42857143em 0 -.21428571em;"></i>
Enter
</div>
</a>
</div>
{% endblock %}

0
ssmembership/__init__.py Normal file
View File

3
ssmembership/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
ssmembership/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class SsmembershipConfig(AppConfig):
name = 'ssmembership'

View File

@ -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 <https://www.gnu.org/licenses/>.
#}
{% block content %}
{% if not member %}
<h1>No membership records</h1>
<p>This email address is not associated with a current membership.</p>
{% else %}
<p>Membership details</p>
{% endif %}
{% endblock %}

View File

44
ssmembership/models.py Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
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()

3
ssmembership/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

23
ssmembership/urls.py Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='membership'),
]

30
ssmembership/views.py Normal file
View File

@ -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 <https://www.gnu.org/licenses/>.
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})