diff --git a/accounts/templates/accounts/profile.html b/accounts/templates/accounts/profile.html index d45772c..0ba520d 100644 --- a/accounts/templates/accounts/profile.html +++ b/accounts/templates/accounts/profile.html @@ -4,6 +4,7 @@ {% block profiletab %} class="active"{% endblock %} + {% block content %}
-
- {% csrf_token %} - {% for form in forms %} - {% bootstrap_form form layout="horizontal" %} - {% endfor %} - {% buttons layout="horizontal" %} - - Change password - {% endbuttons %} -
+ {% include "_form.html" %}
{% endblock %} + +Change password diff --git a/accounts/templates/admin/participants.html b/accounts/templates/admin/participants.html index 50318c2..17262e2 100644 --- a/accounts/templates/admin/participants.html +++ b/accounts/templates/admin/participants.html @@ -2,7 +2,7 @@ {% load bootstrap3 %} -{% block admintab %}active{% endblock %} +{% block admintab %} active{% endblock %} {% block content %} diff --git a/accounts/templates/registration/login.html b/accounts/templates/registration/login.html index b8e03d9..458040b 100644 --- a/accounts/templates/registration/login.html +++ b/accounts/templates/registration/login.html @@ -13,7 +13,7 @@
-
+
{% bootstrap_form form %} diff --git a/accounts/templates/registration/password_change_form.html b/accounts/templates/registration/password_change_form.html index 140a98d..280ac3d 100644 --- a/accounts/templates/registration/password_change_form.html +++ b/accounts/templates/registration/password_change_form.html @@ -11,16 +11,9 @@
-
+
- - {% bootstrap_form form %} - {% csrf_token %} -
- - Cancel -
- + {% include "_form.html" %}
diff --git a/accounts/templates/registration/password_reset_form.html b/accounts/templates/registration/password_reset_form.html index 1eaafd1..82a2daf 100644 --- a/accounts/templates/registration/password_reset_form.html +++ b/accounts/templates/registration/password_reset_form.html @@ -13,14 +13,7 @@
-
- {% bootstrap_form form %} - {% csrf_token %} -
- - Cancel -
-
+ {% include "_form.html" %}
diff --git a/accounts/templates/registration/registration_form.html b/accounts/templates/registration/registration_form.html index dfc9521..f2572ef 100644 --- a/accounts/templates/registration/registration_form.html +++ b/accounts/templates/registration/registration_form.html @@ -13,25 +13,11 @@
-
+
-
- {% bootstrap_form form %} - {% csrf_token %} -
- - Reset your password - Cancel -
-
+ {% include '_form.html' %}
-
-
- You do not have an account? Please register. -
-
- {% endblock %} diff --git a/accounts/urls.py b/accounts/urls.py index 4e51aac..2b78ecd 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -5,8 +5,10 @@ from django.contrib.auth import views as auth_views from . import views urlpatterns = [ + url(r'^register/$', views.Registration.as_view(), name='register'), url(r'^profile/$', views.profile, name='profile'), url(r'^profile/(?P[\w.@+-]+)$', views.edit, name='edit-profile'), + url(r'^login/$', auth_views.login, {'extra_context': {'buttons': [views.RESET_PASSWORD_BUTTON]}}, name='login'), url(r'^logout/$', auth_views.logout, {'next_page': settings.LOGOUT_REDIRECT_URL}, name='logout'), url(r'^admin/participants/$', views.participants, name='participants'), url(r'^admin/participant/(?P[\w.@+-]+)$', views.participant, name='show-participation'), diff --git a/accounts/views.py b/accounts/views.py index 390a4cf..a7ac51b 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -3,18 +3,27 @@ from django.contrib.auth.decorators import login_required from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404, render +from registration.backends.default.views import RegistrationView + from .forms import ParticipationForm, ProfileForm, ProfileOrgaForm, UserForm from .models import Participation, Profile from .utils import can_edit_profile +RESET_PASSWORD_BUTTON = ('password_reset', 'warning', 'Reset your password') +CHANGE_PASSWORD_BUTTON = ('password_change', 'warning', 'Change password') + + +class Registration(RegistrationView): + def get_context_data(self, **kwargs): + return super().get_context_data(buttons=[RESET_PASSWORD_BUTTON], **kwargs) + @login_required def profile(request): forms = [UserForm(request.POST or None, instance=request.user), ProfileForm(request.POST or None, instance=request.user.profile), - ParticipationForm(request.POST or None, instance=Participation.on_site.get(user=request.user)), - ] + ParticipationForm(request.POST or None, instance=Participation.on_site.get(user=request.user))] if request.method == 'POST': if all(form.is_valid() for form in forms): @@ -24,7 +33,7 @@ def profile(request): else: messages.error(request, 'Please correct those errors.') - return render(request, 'accounts/profile.html', {'forms': forms}) + return render(request, 'accounts/profile.html', {'forms': forms, 'buttons': [CHANGE_PASSWORD_BUTTON]}) @login_required diff --git a/ponyconf/templates/_form.html b/ponyconf/templates/_form.html index adef18f..075c5dc 100644 --- a/ponyconf/templates/_form.html +++ b/ponyconf/templates/_form.html @@ -1,9 +1,17 @@ {% load bootstrap3 %}
{% csrf_token %} + {% if form %} {% bootstrap_form form layout="horizontal" %} + {% endif %} + {% for form in forms %} + {% bootstrap_form form layout="horizontal" %} + {% endfor %} {% buttons layout="horizontal" %} + {% for url, class, text in buttons %} + {{ text }} + {% endfor %} + Cancel {% endbuttons %}
- diff --git a/ponyconf/templates/base.html b/ponyconf/templates/base.html index 175c3a4..606a727 100644 --- a/ponyconf/templates/base.html +++ b/ponyconf/templates/base.html @@ -73,7 +73,7 @@  {{ request.user.username }}
  • {% else %} -  Register +  Register  Login {% endif %} diff --git a/proposals/templates/proposals/talk_edit.html b/proposals/templates/proposals/talk_edit.html index f50973d..436e892 100644 --- a/proposals/templates/proposals/talk_edit.html +++ b/proposals/templates/proposals/talk_edit.html @@ -8,12 +8,6 @@

    Propose a talk

    -
    - {% csrf_token %} - {% bootstrap_form form %} - {% buttons %} - - {% endbuttons %} -
    +{% include "_form.html" %} {% endblock %} diff --git a/proposals/templates/proposals/topic_form.html b/proposals/templates/proposals/topic_form.html index 5a30793..fd8a166 100644 --- a/proposals/templates/proposals/topic_form.html +++ b/proposals/templates/proposals/topic_form.html @@ -8,12 +8,6 @@

    Propose a Topic

    -
    - {% csrf_token %} - {% bootstrap_form form %} - {% buttons %} - - {% endbuttons %} -
    +{% include "_form.html" %} {% endblock %}