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. 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. 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) club = models.ForeignKey(Club, verbose_name=_('club'), related_name="members", null=False, blank=False)
start_date = models.DateField(_('start date')) start_date = models.DateField(_('start date'))
end_date = models.DateField(_('end date'), null=True, blank=True) 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 Method to see if that object can be edited by the given user
""" """
if user.membership: if user.memberships:
ms = user.membership.filter(club=self.club, end_date=None).first() 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 (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) return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP)

View File

@ -52,7 +52,7 @@
</div> </div>
</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 #} {# if the user is member of a club, he can view the subscription state #}
<p> <p>
{% if get_subscriber(profile).is_subscribed() %} {% 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 %} {% 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> <li><a href="{{ url('accounting:bank_list') }}">{% trans %}General accounting{% endtrans %}</a></li>
{% endif %} {% 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() %} {%- for b in m.club.bank_accounts.all() %}
<li><strong>{% trans %}Bank account: {% endtrans %}</strong> <li><strong>{% trans %}Bank account: {% endtrans %}</strong>
<a href="{{ url('accounting:bank_details', b_account_id=b.id) }}">{{ b }}</a></li> <a href="{{ url('accounting:bank_details', b_account_id=b.id) }}">{{ b }}</a></li>
@ -58,7 +58,7 @@
<hr> <hr>
<h4>{% trans %}Club tools{% endtrans %}</h4> <h4>{% trans %}Club tools{% endtrans %}</h4>
<ul> <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> <li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -341,7 +341,7 @@ tous les autres.
</ul> </ul>
<h4>Clubs</h4> <h4>Clubs</h4>
<ul> <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> <li><a href="{{ url('club:tools', club_id=m.club.id) }}">{{ m.club }}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>