From ac372412fda13cc6ae80e33959a29ceda1f2407a Mon Sep 17 00:00:00 2001 From: smile Date: Thu, 24 Sep 2015 21:40:54 +0200 Subject: [PATCH] indoor pin and cteward integration --- account/forms.py | 4 +- account/locale/de/LC_MESSAGES/django.mo | Bin 7522 -> 8819 bytes account/locale/de/LC_MESSAGES/django.po | 20 ++--- account/models.py | 1 + account/templates/500.html | 0 account/templates/clabpin.html | 6 +- account/templates/home.html | 35 +++++--- account/templates/member_base.html | 4 +- account/templates/memberstatus.html | 114 ++++++++++++++++++++++++ account/urls.py | 3 +- account/views.py | 39 +++++++- account/wsgi.py | 28 ++++++ requirements.txt | 2 +- 13 files changed, 224 insertions(+), 32 deletions(-) create mode 100644 account/templates/500.html create mode 100644 account/templates/memberstatus.html create mode 100644 account/wsgi.py diff --git a/account/forms.py b/account/forms.py index 1acf493..348626b 100755 --- a/account/forms.py +++ b/account/forms.py @@ -141,8 +141,8 @@ class NRF24Form(forms.Form): class CLabPinForm(forms.Form): - c_lab_pin1 = GastroPinField(label=_('New c-lab PIN')) - c_lab_pin2 = GastroPinField(label=_('Repeat c-lab PIN'), + c_lab_pin1 = GastroPinField(label=_('New indoor PIN')) + c_lab_pin2 = GastroPinField(label=_('Repeat indoor PIN'), help_text=_('Numerical only, 4 to 8 digits')) diff --git a/account/locale/de/LC_MESSAGES/django.mo b/account/locale/de/LC_MESSAGES/django.mo index 61f7a6456005ed1449219c817946c1202d569557..8624a23ba98bc97ea6e8a236bfea1257b898a0fa 100644 GIT binary patch delta 2779 zcmY+Ee{38_702h?{5mIgocMhHaZWO|8;7Jm$Dv7^gtXY$Y2$)jH&5a-N_p^wHT=yp;DY=F>3E_&k)rUV->hugBweVLi~8AHq$%{}{I6U#X2sZ3A1Nyx0rR zz$35+z6xc-58%!4Be(^om@FF)Kp7u^o8es$G1TW{o`53e96SPx@$>U=Sp2_4=Mi`b zij-eQw`1^|@Fn;TY$XM!@wSukS-d<6e*$;Fd)pd;oq{rc3L>rg861EgKuN_qq7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44>Ph4tIf`29lXxqBf%@`XM{NgExbc*6XZJf9 zciwota^DqA3 zPkNbTI^%k?&e=0FCbf_{duEUEB$7PVbK28P;bi`&-qW&+c#O;`ZE$mIt~_!q3+TN-OcroQ@98@zuU_!{b2iM`(pc^K+>dQd*@9oV>~<1F{% blocktrans %}Change your c-lab PIN to access the c-lab in the basement.{% endblocktrans %}

+

{% blocktrans %}Change your PIN to access rooms secured with PIN-pad.{% endblocktrans %}

{% endblock %} {% block form_fields %} @@ -19,4 +19,4 @@ -{% endblock form_fields %} \ No newline at end of file +{% endblock form_fields %} diff --git a/account/templates/home.html b/account/templates/home.html index e7e6e0e..1c8f75f 100644 --- a/account/templates/home.html +++ b/account/templates/home.html @@ -37,21 +37,36 @@

{% trans "Management information" %}

-
    -
  • {% trans "Name:" %} - {{ member.displayName }} -
  • -
  • - {% trans "External e-mail address:" %} - {{ member.externalEmail }}
    + + + + + + + + + + + + + + + + + + + + + + + +
    {% trans "Crewname:" %}{{ cteward.Crewname }}
    {% trans "Membership Number:" %}{{ cteward.Mitgliedsnummer }}
    {% trans "Status:" %}{{ cteward.Status }}
    {% trans "External e-mail address:" %}{{ member.externalEmail }}
    {% trans "Firstname:" %}{{ cteward.Vorname }}
    {% trans "Lastname:" %}{{ cteward.Nachname }}
    {% trans "Street:" %}{{ cteward.Strasse }}
    {% trans "Postcode:" %}{{ cteward.PLZ }}
    {% trans "City:" %}{{ cteward.Ort }}
    {% trans "Gender:" %}{{ cteward.Geschlecht }}
    {% trans "Birth Date:" %}{{ cteward.Geburtsdatum }}
    {% trans "Entry Date:" %}{{ cteward.Eintritt }}
    {% trans "Godfather:" %}{{ cteward.Paten }}
    {% trans "Payment Method:" %}{{ cteward.Zahlungsart }}
    {% trans "Payment Frequency:" %}{{ cteward.Zahlungsweise }}
    {% trans "Debit Authorization:" %}{{ cteward.Lastschriftmandat }}
    {% trans "Bank:" %}{{ cteward.Bank }}
    {% trans "IBAN:" %}{{ cteward.IBAN }}
    {% trans "BIC:" %}{{ cteward.BIC }}
    {% endblock container %} diff --git a/account/templates/member_base.html b/account/templates/member_base.html index 6b850e9..97214bf 100644 --- a/account/templates/member_base.html +++ b/account/templates/member_base.html @@ -26,7 +26,7 @@
  • {% url account.views.clabpin as clab_url %}
  • - {% trans "c-lab-PIN" %} + {% trans "Indoor-PIN" %}
  • {% url account.views.nrf24 as nrf24_url %}
  • @@ -50,7 +50,7 @@
    - Copyright © 2013 by c-base e.V. + Copyright © 2015 by c-base e.V.
    {% endblock body %} diff --git a/account/templates/memberstatus.html b/account/templates/memberstatus.html new file mode 100644 index 0000000..f5dd84b --- /dev/null +++ b/account/templates/memberstatus.html @@ -0,0 +1,114 @@ +{% extends "member_base.html" %} +{% load i18n %} + +{% block container %} +
    +
    +

    {% trans "Basic information about your account" %}

    + + {{ contributions }} + + + + + + + + + + + + + + + + + + + + +
    {% trans "Crewname:" %}{{ cteward.Crewname }}
    {% trans "Membership Number:" %}{{ cteward.Mitgliedsnummer }}
    {% trans "Status:" %}{{ cteward.Status }}
    {% trans "Firstname:" %}{{ cteward.Vorname }}
    {% trans "Lastname:" %}{{ cteward.Nachname }}
    {% trans "Street:" %}{{ cteward.Strasse }}
    {% trans "Postcode:" %}{{ cteward.PLZ }}
    {% trans "City:" %}{{ cteward.Ort }}
    {% trans "Gender:" %}{{ cteward.Geschlecht }}
    {% trans "Birth Date:" %}{{ cteward.Geburtsdatum }}
    {% trans "Entry Date:" %}{{ cteward.Eintritt }}
    {% trans "Godfather:" %}{{ cteward.Paten }}
    {% trans "Payment Method:" %}{{ cteward.Zahlungsart }}
    {% trans "Payment Frequency:" %}{{ cteward.Zahlungsweise }}
    {% trans "Debit Authorization:" %}{{ cteward.Lastschriftmandat }}
    {% trans "Bank:" %}{{ cteward.Bank }}
    {% trans "IBAN:" %}{{ cteward.IBAN }}
    {% trans "BIC:" %}{{ cteward.BIC }}
    +
    +
    +
    +
    +
    +

    {% trans "Contributions:" %}

    +
    +
    +
    + {% trans "Total" %} +
    +
    + + + + +
    {% trans "Billed:" %}{{ contributions.total.billed }}
    {% trans "Paid:" %}{{ contributions.total.paid }}
    {% trans "Unpaid:" %}{{ contributions.total.unpaid }}
    +
    +
    +
    + {% for year,values in contributions.years %} +
    + {{ year }} +
    +
    + + + + +
    {% trans "Billed:" %}{{ values.billed }}
    {% trans "Paid:" %}{{ values.paid }}
    {% trans "Unpaid:" %}{{ values.unpaid }}
    +
    +
    +
    + {% empty %} + {% trans "no data available" %} + {% endfor %} +
    +
    +
    +
    +
    +
    +

    {% trans "Contracts:" %}

    +
    +
    + {% for contract in contributions.contracts %} +
    + Contract #{{ contract.Vertragsnummer }} +
    +
    + + + + +
    {% trans "Type:" %}{{ contract.Art }}
    {% trans "Total:" %} + + + + + + +
    {% trans "Billed:" %}{{ contract.total.billed }}{% trans "Paid:" %}{{ contract.total.paid }}{% trans "Unpaid:" %}{{ contract.total.unpaid }}
    +
    {% trans "Sums:" %} + + {% for detail, values in contract.Summen.items %} + + + + + + + {% endfor %} +
    {{ detail }}:{% trans "Billed:" %}{{ values.billed }}{% trans "Paid:" %}{{ values.paid }}{% trans "Unpaid:" %}{{ values.unpaid }}
    +
    +
    +
    +
    + {% empty %} + {% trans "no data available" %} + {% endfor %} +
    +
    +
    +{% endblock container %} diff --git a/account/urls.py b/account/urls.py index d4ff5f6..1a67e1f 100644 --- a/account/urls.py +++ b/account/urls.py @@ -13,6 +13,7 @@ urlpatterns = patterns( url(r'^sippin/$', 'account.views.sippin', name='sippin'), url(r'^clabpin/$', 'account.views.clabpin', name='clabpin'), url(r'^admin/$', 'account.views.admin', name='admin'), + url(r'^memberstatus/$', 'account.views.memberstatus', name='memberstatus'), url(r'^$', 'account.views.home', name="home"), url(r'^groups/(?P[^/]+)/', 'account.views.groups_list'), -) \ No newline at end of file +) diff --git a/account/views.py b/account/views.py index 75d370c..cc6ee12 100644 --- a/account/views.py +++ b/account/views.py @@ -4,6 +4,8 @@ import os import hashlib import smbpasswd +import requests +import collections from django.conf import settings from django.http import HttpResponse, HttpResponseRedirect @@ -82,9 +84,16 @@ def auth_login(request): def home(request): member = retrieve_member(request) number_of_members = member.get_number_of_members() + password = get_ldap_password(request) + username = request.user.username + url = "https://vorstand.c-base.org/cteward-api/legacy/member/%s" % username + r = requests.get(url, verify=False, auth=(username, password)) + cteward = r.json() context = {'member': member.to_dict(), 'groups': sorted(list(request.user.groups.all())), - 'number_of_members': number_of_members} + 'number_of_members': number_of_members, + 'cteward': cteward, + } return render(request, 'home.html', context) @login_required @@ -151,8 +160,11 @@ def gastropin(request): @login_required def clabpin(request): - if not (request.user.profile.is_clab_member or request.user.profile.is_cey_member): - #if not request.user.profile.is_clab_member: + if not ( + request.user.profile.is_clab_member or + request.user.profile.is_cey_member or + request.user.profile.is_soundlab_member + ): return render(request, 'access_denied.html') def calculate_clab_hash(pin): @@ -280,3 +292,24 @@ def admin(request): def hammertime(request): return render(request, 'hammertime.html', {}) + +@login_required +def memberstatus(request): + #url = baseurl + route_operation_mapping['SessionCreate']['Route'] + #data = json.dumps({'UserLogin': username, 'Password': password}) + password = get_ldap_password(request) + username = request.user.username + + url = "https://vorstand.c-base.org/cteward-api/legacy/member/%s/contributions" % username + r = requests.get(url, verify=False, auth=(username, password)) + contributions = r.json() + years = collections.OrderedDict(sorted(contributions['years'].items(), reverse=True)) + contributions['years'] = years.items() + + url = "https://vorstand.c-base.org/cteward-api/legacy/member/%s" % username + r = requests.get(url, verify=False, auth=(username, password)) + cteward = r.json() + + return render(request, 'memberstatus.html', {'contributions': contributions, 'cteward': cteward}) + + diff --git a/account/wsgi.py b/account/wsgi.py new file mode 100644 index 0000000..612f1eb --- /dev/null +++ b/account/wsgi.py @@ -0,0 +1,28 @@ +""" +WSGI config for cbmi project. + +This module contains the WSGI application used by Django's development server +and any production WSGI deployments. It should expose a module-level variable +named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover +this application via the ``WSGI_APPLICATION`` setting. + +Usually you will have the standard Django WSGI application here, but it also +might make sense to replace the whole Django WSGI application with a custom one +that later delegates to the Django one. For example, you could introduce WSGI +middleware here, or combine a Django application with an application of another +framework. + +""" +import os + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cbmi.settings") + +# This application object is used by any WSGI server configured to use this +# file. This includes Django's development server, if the WSGI_APPLICATION +# setting points here. +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() + +# Apply WSGI middleware here. +# from helloworld.wsgi import HelloWorldApplication +# application = HelloWorldApplication(application) diff --git a/requirements.txt b/requirements.txt index c17f2f0..de20139 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Django==1.4.2 -MySQL-python==1.2.4 +#MySQL-python==1.2.4 django-auth-ldap==1.1.4 django-json-rpc==0.6.1 django-crispy-forms==1.4.0