Add first Matmat' app

This commit is contained in:
Skia
2017-05-09 23:42:01 +02:00
parent 5060114305
commit b3bc33a319
15 changed files with 460 additions and 1 deletions

View File

@ -0,0 +1,26 @@
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}Preferences{% endtrans %}
{% endblock %}
{% block content %}
<h2>{% trans %}Preferences{% endtrans %}</h2>
<form action="" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p() }}
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form>
{% if matmat_form %}
<form action="{{ url('matmat:user_tools') }}" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ matmat_form.as_p() }}
<p><input type="submit" value="{% trans %}Save{% endtrans %}" /></p>
</form>
{% else %}
<p><a href="{{ url('matmat:user_tools') }}">Matmatronch tools</a></p>
{% endif %}
{% endblock %}

View File

@ -46,6 +46,7 @@ from core.views.forms import RegisteringForm, UserPropForm, UserProfileForm, Log
from core.models import User, SithFile, Preferences
from club.models import Club
from subscription.models import Subscription
from matmat.views import UserMatmatForm
def login(request):
"""
@ -427,7 +428,7 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
"""
model = User
pk_url_kwarg = "user_id"
template_name = "core/edit.jinja"
template_name = "core/user_preferences.jinja"
form_class = modelform_factory(Preferences, fields=['receive_weekmail'])
context_object_name = "profile"
current_tab = "prefs"
@ -446,6 +447,12 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
kwargs.update({'instance': pref})
return kwargs
def get_context_data(self, **kwargs):
kwargs = super(UserPreferencesView, self).get_context_data(**kwargs)
if not hasattr(self.object, 'matmat_user'):
kwargs['matmat_form'] = UserMatmatForm()
return kwargs
class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
"""
Edit a user's groups