Rename membership to memberships

This commit is contained in:
Skia 2016-09-15 11:06:51 +02:00
parent 3d9dfbc43a
commit 6aaeb7cdc9
5 changed files with 27 additions and 7 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('club', '0003_auto_20160902_2042'),
]
operations = [
migrations.AlterField(
model_name='membership',
name='user',
field=models.ForeignKey(verbose_name='user', related_name='memberships', to=settings.AUTH_USER_MODEL),
),
]

View File

@ -141,7 +141,7 @@ class Membership(models.Model):
A User is currently member of all the Clubs where its Membership has an end_date set to null/None.
Otherwise, it's a past membership kept because it can be very useful to see who was in which Club in the past.
"""
user = models.ForeignKey(User, verbose_name=_('user'), related_name="membership", null=False, blank=False)
user = models.ForeignKey(User, verbose_name=_('user'), related_name="memberships", null=False, blank=False)
club = models.ForeignKey(Club, verbose_name=_('club'), related_name="members", null=False, blank=False)
start_date = models.DateField(_('start date'))
end_date = models.DateField(_('end date'), null=True, blank=True)
@ -176,8 +176,8 @@ class Membership(models.Model):
"""
Method to see if that object can be edited by the given user
"""
if user.membership:
ms = user.membership.filter(club=self.club, end_date=None).first()
if user.memberships:
ms = user.memberships.filter(club=self.club, end_date=None).first()
return (ms and ms.role >= self.role) or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP)
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP)

View File

@ -52,7 +52,7 @@
</div>
</div>
{% if user.membership.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user == profile %}
{% if user.memberships.filter(end_date=None).exists() or user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user == profile %}
{# if the user is member of a club, he can view the subscription state #}
<p>
{% if get_subscriber(profile).is_subscribed() %}

View File

@ -42,7 +42,7 @@
{% if user.is_in_group(settings.SITH_GROUPS['accounting-admin']['name']) or user.is_root %}
<li><a href="{{ url('accounting:bank_list') }}">{% trans %}General accounting{% endtrans %}</a></li>
{% endif %}
{% for m in user.membership.filter(end_date=None).filter(role__gte=7).all() -%}
{% for m in user.memberships.filter(end_date=None).filter(role__gte=7).all() -%}
{%- for b in m.club.bank_accounts.all() %}
<li><strong>{% trans %}Bank account: {% endtrans %}</strong>
<a href="{{ url('accounting:bank_details', b_account_id=b.id) }}">{{ b }}</a></li>
@ -58,7 +58,7 @@
<hr>
<h4>{% trans %}Club tools{% endtrans %}</h4>
<ul>
{% for m in user.membership.filter(end_date=None).all() %}
{% for m in user.memberships.filter(end_date=None).all() %}
<li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
{% endfor %}
</ul>

View File

@ -341,7 +341,7 @@ tous les autres.
</ul>
<h4>Clubs</h4>
<ul>
{% for m in user.membership.filter(end_date=None).all() %} {# (6) #}
{% for m in user.memberships.filter(end_date=None).all() %} {# (6) #}
<li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
{% endfor %}
</ul>