Skip to content

Commit

Permalink
Refactor accounts, registration, stats
Browse files Browse the repository at this point in the history
* remove stats model
* move volunteer_stats template tag to common app
* refactoring for removed registration code
  • Loading branch information
christophmeissner committed Oct 1, 2015
1 parent 9297f2f commit 827a9c9
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_volunteer_hours():
"""
finished_needs = Need.objects.filter(
starting_time__lte=timezone.now()).annotate(
slots_done=Count('registrationprofile'))
slots_done=Count('helpers'))
delta = timedelta()
for need in finished_needs:
delta += need.slots_done * (need.ending_time - need.starting_time)
Expand Down
34 changes: 17 additions & 17 deletions locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ msgid "Password"
msgstr "Passwort"

#: templates/registration/login.html:43
#: templates/registration/password_reset_form.html:6
#: templates/registration/auth_password_reset_form.html:6
msgid "Forgot your password?"
msgstr "Passwort vergessen?"

Expand Down Expand Up @@ -698,52 +698,52 @@ msgstr "Passwort ändern"

#: templates/registration/password_change_form.html:11
#: templates/registration/password_change_form.html:13
#: templates/registration/password_reset_form.html:12
#: templates/registration/password_reset_form.html:14
#: templates/registration/auth_password_reset_form.html:12
#: templates/registration/auth_password_reset_form.html:14
msgid "Email address"
msgstr "E-Mailadresse"

#: templates/registration/password_change_form.html:15
#: templates/registration/password_reset_confirm.html:13
#: templates/registration/auth_password_reset_confirm.html:13
msgid "Change password"
msgstr "Passwort ändern"

#: templates/registration/password_reset_complete.html:3
#: templates/registration/auth_password_reset_complete.html:3
msgid "Password reset complete"
msgstr "Passwort wurde geändert"

#: templates/registration/password_reset_complete.html:8
#: templates/registration/auth_password_reset_complete.html:8
msgctxt "login link title reset password complete page"
msgid "log in"
msgstr "einloggen"

#: templates/registration/password_reset_complete.html:9
#: templates/registration/auth_password_reset_complete.html:9
#, python-format
msgctxt "reset password complete page"
msgid "Your password has been reset! You may now %(login_link)s again."
msgstr "Dein Passwort wurde geändert. Du kannst dich jetzt wieder %(login_link)s."

#: templates/registration/password_reset_confirm.html:3
#: templates/registration/auth_password_reset_confirm.html:3
msgid "Enter new password"
msgstr "Neues Passwort festlegen"

#: templates/registration/password_reset_confirm.html:6
#: templates/registration/auth_password_reset_confirm.html:6
msgid "Enter your new password below to reset your password"
msgstr "Bitte gib dein neues Passwort ein"

#: templates/registration/password_reset_done.html:3
#: templates/registration/auth_password_reset_done.html:3
msgid "Password reset"
msgstr "Passwort zurückgesetzt"

#: templates/registration/password_reset_done.html:6
#: templates/registration/auth_password_reset_done.html:6
msgid "We sent you an email with a link to reset your password."
msgstr "Wir haben Dir eine E-Mail mit der Anleitung zum Ändern des Passwortes geschickt."

#: templates/registration/password_reset_done.html:7
#: templates/registration/auth_password_reset_done.html:7
msgid "Please check your email and click the link to continue."
msgstr "Bitte prüfe Deine E-Mails und folge der Anleitung um fortzufahren."

#: templates/registration/password_reset_email.html:3
#: templates/registration/auth_password_reset_email.html:3
#, python-format
msgid ""
"You are receiving this email because you (or someone pretending to be you)\n"
Expand All @@ -759,7 +759,7 @@ msgstr ""
"\n"
"Um Dein Passwort zu ändern, klicke bitte folgenden Link:"

#: templates/registration/password_reset_email.html:12
#: templates/registration/auth_password_reset_email.html:12
#, python-format
msgid ""
"\n"
Expand All @@ -774,12 +774,12 @@ msgstr ""
"Viele Grüße,\n"
"das %(site_name)s-Team\n"

#: templates/registration/password_reset_form.html:3
#: templates/registration/password_reset_form.html:16
#: templates/registration/auth_password_reset_form.html:3
#: templates/registration/auth_password_reset_form.html:16
msgid "Reset password"
msgstr "Passwort zurücksetzen"

#: templates/registration/password_reset_form.html:7
#: templates/registration/auth_password_reset_form.html:7
msgid "No Problem! We'll send you instructions on how to reset your password."
msgstr "Kein Problem! Wir schicken Dir eine E-Mail mit der Anleitung wie Du Dein Passort zurücksetzen kannst."

Expand Down
34 changes: 17 additions & 17 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ msgid "Password"
msgstr ""

#: templates/registration/login.html:43
#: templates/registration/password_reset_form.html:6
#: templates/registration/auth_password_reset_form.html:6
msgid "Forgot your password?"
msgstr ""

Expand Down Expand Up @@ -695,52 +695,52 @@ msgstr ""

#: templates/registration/password_change_form.html:11
#: templates/registration/password_change_form.html:13
#: templates/registration/password_reset_form.html:12
#: templates/registration/password_reset_form.html:14
#: templates/registration/auth_password_reset_form.html:12
#: templates/registration/auth_password_reset_form.html:14
msgid "Email address"
msgstr ""

#: templates/registration/password_change_form.html:15
#: templates/registration/password_reset_confirm.html:13
#: templates/registration/auth_password_reset_confirm.html:13
msgid "Change password"
msgstr ""

#: templates/registration/password_reset_complete.html:3
#: templates/registration/auth_password_reset_complete.html:3
msgid "Password reset complete"
msgstr ""

#: templates/registration/password_reset_complete.html:8
#: templates/registration/auth_password_reset_complete.html:8
msgctxt "login link title reset password complete page"
msgid "log in"
msgstr ""

#: templates/registration/password_reset_complete.html:9
#: templates/registration/auth_password_reset_complete.html:9
#, python-format
msgctxt "reset password complete page"
msgid "Your password has been reset! You may now %(login_link)s again."
msgstr ""

#: templates/registration/password_reset_confirm.html:3
#: templates/registration/auth_password_reset_confirm.html:3
msgid "Enter new password"
msgstr ""

#: templates/registration/password_reset_confirm.html:6
#: templates/registration/auth_password_reset_confirm.html:6
msgid "Enter your new password below to reset your password"
msgstr ""

#: templates/registration/password_reset_done.html:3
#: templates/registration/auth_password_reset_done.html:3
msgid "Password reset"
msgstr ""

#: templates/registration/password_reset_done.html:6
#: templates/registration/auth_password_reset_done.html:6
msgid "We sent you an email with a link to reset your password."
msgstr ""

#: templates/registration/password_reset_done.html:7
#: templates/registration/auth_password_reset_done.html:7
msgid "Please check your email and click the link to continue."
msgstr ""

#: templates/registration/password_reset_email.html:3
#: templates/registration/auth_password_reset_email.html:3
#, python-format
msgid ""
"You are receiving this email because you (or someone pretending to be you)\n"
Expand All @@ -751,7 +751,7 @@ msgid ""
"into your web browser:"
msgstr ""

#: templates/registration/password_reset_email.html:12
#: templates/registration/auth_password_reset_email.html:12
#, python-format
msgid ""
"\n"
Expand All @@ -761,12 +761,12 @@ msgid ""
"%(site_name)s Management\n"
msgstr ""

#: templates/registration/password_reset_form.html:3
#: templates/registration/password_reset_form.html:16
#: templates/registration/auth_password_reset_form.html:3
#: templates/registration/auth_password_reset_form.html:16
msgid "Reset password"
msgstr ""

#: templates/registration/password_reset_form.html:7
#: templates/registration/auth_password_reset_form.html:7
msgid "No Problem! We'll send you instructions on how to reset your password."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion non_logged_in_area/templates/faqs.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h4 class="card-title">
<p class="card-text">
<ol>
<li>
<a href="{% url 'registation' %}" target="_blank">
<a href="{% url 'registation_register' %}" target="_blank">
{% blocktrans trimmed context "FAQ A1.1" %}
Create an account.
{% endblocktrans %}
Expand Down
4 changes: 2 additions & 2 deletions non_logged_in_area/templates/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "base_non_logged_in.html" %}

{% load volunteer_numbers humanize i18n cache %}
{% load volunteer_stats humanize i18n cache %}

{% block stage %}
<!-- Full Width Image Header -->
Expand All @@ -23,7 +23,7 @@ <h1>{% trans "Volunteers Helping Refugees" %}</h1>
</div>

<div class="col-md-4">
<a id="help-cta" href="{% url 'registration' %}">
<a id="help-cta" href="{% url 'registration_register' %}">
<h2>{% trans "I want to help!" %}</h2>
<hr/>
<p>{% trans "Register and see where you can help" %}</p>
Expand Down
25 changes: 16 additions & 9 deletions non_logged_in_area/templates/shelters_need_help.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
{% extends "base_non_logged_in.html" %}

{% load volunteer_numbers humanize i18n cache %}
{% load humanize i18n cache %}

{% block stage %}
<!-- Full Width Image Header -->
<header class="header-image">
<div id="stage">
<div class="container">
<h1>Freiwilligenarbeit übersichtlich und einfach organisieren</h1>
<h1>Freiwilligenarbeit übersichtlich und einfach
organisieren</h1>
</div>
</div>
</header>

{% endblock %}

{% block content %}
<div class="spacer"></div>
<div class="col-md-6">
<h2>Die richtige Hilfe zur Richtigen Zeit.</h2>

<p>Sehr viele Menschen wollen helfen. Das ist super! Leider ist oft nicht klar, wie wann und wo geholfen werden
kann. Das möchten wir ändern! Über volunteer-planner.org können die Koordinator_innen der
<p>Sehr viele Menschen wollen helfen. Das ist super! Leider ist oft
nicht klar, wie wann und wo geholfen werden
kann. Das möchten wir ändern! Über volunteer-planner.org können die
Koordinator_innen der
Flüchtlingsunterkünfte
übersichtlich auflisten wo wann welche Hilfe benötigt wird. Freiwillige können dann auf einem Blick sehen
übersichtlich auflisten wo wann welche Hilfe benötigt wird.
Freiwillige können dann auf einem Blick sehen
wie
sie helfen können und sich sofort für eine Schicht eintragen.</p>
</div>

<div class="col-md-6">
<h2>Kostenlos. Werbefrei.</h2>

<p>Die Plattform wird von einer Gruppe von Freiwilligen aufgebaut, betreut und weiterentwickelt. Sie steht
kostenlos und werbefrei zur Verfügung. Sämtliche Daten werden nicht weitergegeben oder weiterverkauft.</p>
<p>Die Plattform wird von einer Gruppe von Freiwilligen aufgebaut,
betreut und weiterentwickelt. Sie steht
kostenlos und werbefrei zur Verfügung. Sämtliche Daten werden nicht
weitergegeben oder weiterverkauft.</p>
</div>
{% endblock %}
{% endblock %}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Migration(migrations.Migration):
(b'registration', '0004_auto_20150903_2258'),
(b'registration', '0004_auto_20150830_1945'),
(b'registration', '0004_auto_20150822_1800'),
(b'registration', '0006_auto_20150917_2328'),
(b'registration', '0005_merge'),
(b'registration', '0006_remove_registrationprofile_interests'),
(b'registration', '0002_registrationprofile_activated'),
Expand Down
6 changes: 3 additions & 3 deletions scheduler/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
class NeedAdmin(admin.ModelAdmin):
def get_queryset(self, request):
return super(NeedAdmin, self).get_queryset(request) \
.annotate(volunteer_count=Count('registrationprofile')) \
.prefetch_related('registrationprofile_set',
'registrationprofile_set__user')
.annotate(volunteer_count=Count('helpers')) \
.prefetch_related('helpers',
'helpers__user')

def get_volunteer_count(self, obj):
return obj.volunteer_count
Expand Down
43 changes: 26 additions & 17 deletions scheduler/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
import logging

from django.core.urlresolvers import reverse

from django.contrib import messages

from django.db.models import Count

from django.views.generic import TemplateView, FormView, DetailView

from django.shortcuts import get_object_or_404

from django.utils.translation import ugettext_lazy as _

from accounts.models import UserAccount
from scheduler.models import Location, Need
from scheduler.models import Location, Need, ShiftHelper
from notifications.models import Notification
from .forms import RegisterForNeedForm
from volunteer_planner.utils import LoginRequiredMixin
Expand Down Expand Up @@ -54,14 +50,14 @@ def get_context_data(self, **kwargs):
context = super(PlannerView, self).get_context_data(**kwargs)

context['needs'] = Need.objects.filter(location__pk=self.kwargs['pk']) \
.annotate(volunteer_count=Count('registrationprofile')) \
.annotate(volunteer_count=Count('helpers')) \
.filter(ending_time__year=self.kwargs['year'],
ending_time__month=self.kwargs['month'],
ending_time__day=self.kwargs['day']) \
.order_by('topic', 'ending_time') \
.select_related('topic', 'location') \
.prefetch_related('registrationprofile_set',
'registrationprofile_set__user')
.prefetch_related('helpers',
'helpers__user')

context['location'] = get_object_or_404(Location, pk=self.kwargs['pk'])
context['schedule_date'] = datetime.date(int(self.kwargs['year']),
Expand All @@ -80,13 +76,13 @@ def form_valid(self, form):
messages.warning(self.request, _(u'User account does not exist.'))
return super(PlannerView, self).form_valid(form)

join_shift = form.cleaned_data.get("join_shift")
leave_shift = form.cleaned_data.get("leave_shift")
shift_to_join = form.cleaned_data.get("join_shift")
shift_to_leave = form.cleaned_data.get("leave_shift")

print(form.cleaned_data)

if join_shift:
conflicts = join_shift.get_conflicting_needs(
if shift_to_join:
conflicts = shift_to_join.get_conflicting_needs(
user_account.needs.all())
if conflicts:
conflicts_string = u", ".join(
Expand All @@ -97,13 +93,26 @@ def form_valid(self, form):
conflicts=
conflicts_string)))
else:
messages.success(self.request, _(
u'You were successfully added to this shift.'))
user_account.needs.add(join_shift)
elif leave_shift:
# user_account.needs.add(join_shift)
shift_helper, created = ShiftHelper.objects.get_or_create(
user_account=user_account, need=shift_to_join)
if created:
messages.success(self.request, _(
u'You were successfully added to this shift.'))
else:
messages.warning(self.request, _(
u'You already signed up for this shift at {date_time}.').format(
date_time=shift_helper.joined_shift_at))
elif shift_to_leave:
try:
ShiftHelper.objects.get(user_account=user_account,
need=shift_to_leave).delete()
except ShiftHelper.DoesNotExist:
# just catch the exception, user seems not to have signed up for this shift tho
pass
messages.success(self.request, _(
u'You successfully left this shift.'))
user_account.needs.remove(leave_shift)

user_account.save()
return super(PlannerView, self).form_valid(form)

Expand Down
Loading

0 comments on commit 827a9c9

Please sign in to comment.