1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-23 07:52:23 +00:00

Merge branch 'form_improve' into 'master'

Form improve

Closes #28

See merge request bde/nk20!25
This commit is contained in:
Pierre-antoine Comby 2020-02-26 13:23:54 +01:00
commit c93bd3c458
5 changed files with 19 additions and 13 deletions

View File

@ -14,6 +14,11 @@ from crispy_forms.layout import Layout
class SignUpForm(UserCreationForm):
def __init__(self,*args,**kwargs):
super().__init__(*args,**kwargs)
self.fields['username'].widget.attrs.pop("autofocus", None)
self.fields['first_name'].widget.attrs.update({"autofocus":"autofocus"})
class Meta:
model = User
fields = ['first_name', 'last_name', 'username', 'email']

View File

@ -114,12 +114,13 @@ class UserDetailView(LoginRequiredMixin, DetailView):
"""
Affiche les informations sur un utilisateur, sa note, ses clubs...
"""
model = Profile
context_object_name = "profile"
model = User
context_object_name = "user_object"
template_name = "member/profile_detail.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
user = context['profile'].user
user = context['user_object']
history_list = \
Transaction.objects.all().filter(Q(source=user.note) | Q(destination=user.note))
context['history_list'] = HistoryTable(history_list)

View File

@ -87,7 +87,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</a>
<div class="dropdown-menu dropdown-menu-right"
aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="{% url 'member:user_detail' pk=user.profile.pk %}">
<a class="dropdown-item" href="{% url 'member:user_detail' pk=user.pk %}">
<i class="fa fa-user"></i> Mon compte
</a>
<a class="dropdown-item" href="{% url 'logout' %}">

View File

@ -5,14 +5,14 @@
<div class="row mt-4">
<div class="col-md-3 mb-4">
<div class="card bg-light shadow">
<img src="{{ object.note.display_image.url }}" class="card-img-top" alt="">
<img src="{{ object.note.display_image }}" class="card-img-top" alt="">
<div class="card-body">
<dl class="row">
<dt class="col-xl-6">{% trans 'name'|capfirst %}, {% trans 'first name' %}</dt>
<dd class="col-xl-6">{{ object.user.last_name }} {{ object.user.first_name }}</dd>
<dd class="col-xl-6">{{ object.last_name }} {{ object.first_name }}</dd>
<dt class="col-xl-6">{% trans 'username'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.user.username }}</dd>
<dd class="col-xl-6">{{ user.username }}</dd>
<dt class="col-xl-6">{% trans 'password'|capfirst %}</dt>
<dd class="col-xl-6">
@ -22,19 +22,19 @@
</dd>
<dt class="col-xl-6">{% trans 'section'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.section }}</dd>
<dd class="col-xl-6">{{ object.profile.section }}</dd>
<dt class="col-xl-6">{% trans 'address'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.address }}</dd>
<dd class="col-xl-6">{{ object.profile.address }}</dd>
<dt class="col-xl-6">{% trans 'balance'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.user.note.balance | pretty_money }}</dd>
<dd class="col-xl-6">{{ object.note.balance | pretty_money }}</dd>
<dt class="col-xl-6">{% trans 'aliases'|capfirst %}</dt>
<dd class="col-xl-6">{{ object.user.note.alias_set.all|join:", " }}</dd>
<dd class="col-xl-6">{{ object.note.alias_set.all|join:", " }}</dd>
</dl>
{% if object.user.pk == user.pk %}
{% if object.pk == user.pk %}
<a class="small" href="{% url 'member:auth_token' %}">{% trans 'Manage auth token' %}</a>
{% endif %}
</div>

View File

@ -10,7 +10,7 @@
{% csrf_token %}
{{ form|crispy }}
{{ profile_form|crispy }}
<button class="btn btn-link" type="submit">
<button class="btn btn-success" type="submit">
{% trans "Sign Up" %}
</button>
</form>