From 2d16b9c296e26cd8f9794035983b9701dac7bb96 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Wed, 21 Sep 2016 13:33:02 +0200 Subject: [PATCH 1/4] Hided launderette slots and tokens for non authorized users and added is_office and is_launderette --- core/models.py | 10 ++++++++++ core/templates/core/user_detail.jinja | 16 +++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/models.py b/core/models.py index 136469df..fb5c4137 100644 --- a/core/models.py +++ b/core/models.py @@ -231,6 +231,16 @@ class User(AbstractBaseUser): def is_root(self): return self.is_superuser or self.groups.filter(name=settings.SITH_GROUPS['root']['name']).exists() + @property + def is_office(self): + from club.models import Club + return Club.objects.filter(unix_name='laverie').first().get_membership_for(self) + + @property + def is_launderette(self): + from club.models import Club + return Club.objects.filter(unix_name='').first().get_membership_for(self) + def save(self, *args, **kwargs): create = False with transaction.atomic(): diff --git a/core/templates/core/user_detail.jinja b/core/templates/core/user_detail.jinja index f9696be0..e4d326b1 100644 --- a/core/templates/core/user_detail.jinja +++ b/core/templates/core/user_detail.jinja @@ -56,14 +56,16 @@ {# if the user is member of a club, he can view the subscription state #}

{% if get_subscriber(profile).is_subscribed() %} - {% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}
- {% if user == profile or user.is_root %} - {% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}
+ {% if user == profile or user.is_root or user.is_office %} + {% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}
+ {% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}
+ {% endif %} + {% if user == profile or user.is_root or user.is_office or user.is_launderette %} + {# Shows tokens bought by the user #} + {{ show_tokens(profile) }} + {# Shows slots took by the user #} + {{ show_slots(profile) }} {% endif %} - {# Shows tokens bought by the user #} - {{ show_tokens(profile) }} - {# Shows slots took by the user #} - {{ show_slots(profile) }} {% else %} {% trans %}Not subscribed{% endtrans %} {% if user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) %} From 748ad1c5c21b10a551335771e239f41cd0c8ada1 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Wed, 21 Sep 2016 14:01:44 +0200 Subject: [PATCH 2/4] Fixed some mistakes --- core/models.py | 7 +------ core/templates/core/user_detail.jinja | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/core/models.py b/core/models.py index fb5c4137..d0d6c8bf 100644 --- a/core/models.py +++ b/core/models.py @@ -234,12 +234,7 @@ class User(AbstractBaseUser): @property def is_office(self): from club.models import Club - return Club.objects.filter(unix_name='laverie').first().get_membership_for(self) - - @property - def is_launderette(self): - from club.models import Club - return Club.objects.filter(unix_name='').first().get_membership_for(self) + return Club.objects.filter(unix_name='ae').first().get_membership_for(self) def save(self, *args, **kwargs): create = False diff --git a/core/templates/core/user_detail.jinja b/core/templates/core/user_detail.jinja index e4d326b1..8cfca543 100644 --- a/core/templates/core/user_detail.jinja +++ b/core/templates/core/user_detail.jinja @@ -59,8 +59,6 @@ {% if user == profile or user.is_root or user.is_office %} {% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}
{% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}
- {% endif %} - {% if user == profile or user.is_root or user.is_office or user.is_launderette %} {# Shows tokens bought by the user #} {{ show_tokens(profile) }} {# Shows slots took by the user #} From e250acf82db0e66871c8d9604f0607fb6ddf7443 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Thu, 22 Sep 2016 13:00:00 +0200 Subject: [PATCH 3/4] Used settings for office and launderette --- core/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/models.py b/core/models.py index d0d6c8bf..c7cee3a9 100644 --- a/core/models.py +++ b/core/models.py @@ -234,7 +234,12 @@ class User(AbstractBaseUser): @property def is_office(self): from club.models import Club - return Club.objects.filter(unix_name='ae').first().get_membership_for(self) + return Club.objects.filter(unix_name=settings.SITH_MAIN_CLUB['unix_name']).first().get_membership_for(self) + + @property + def is_launderette(self): + from club.models import Club + return Club.objects.filter(unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name']).first().get_membership_for(self) def save(self, *args, **kwargs): create = False From 380f41445ab31a25dbc522a6299c41746ef7d396 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Thu, 22 Sep 2016 13:07:22 +0200 Subject: [PATCH 4/4] Modify property names --- core/models.py | 4 ++-- core/templates/core/user_detail.jinja | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/models.py b/core/models.py index c7cee3a9..1a67237a 100644 --- a/core/models.py +++ b/core/models.py @@ -232,12 +232,12 @@ class User(AbstractBaseUser): return self.is_superuser or self.groups.filter(name=settings.SITH_GROUPS['root']['name']).exists() @property - def is_office(self): + def is_board_member(self): from club.models import Club return Club.objects.filter(unix_name=settings.SITH_MAIN_CLUB['unix_name']).first().get_membership_for(self) @property - def is_launderette(self): + def is_launderette_manager(self): from club.models import Club return Club.objects.filter(unix_name=settings.SITH_LAUNDERETTE_MANAGER['unix_name']).first().get_membership_for(self) diff --git a/core/templates/core/user_detail.jinja b/core/templates/core/user_detail.jinja index 8cfca543..800e2b2a 100644 --- a/core/templates/core/user_detail.jinja +++ b/core/templates/core/user_detail.jinja @@ -56,9 +56,11 @@ {# if the user is member of a club, he can view the subscription state #}

{% if get_subscriber(profile).is_subscribed() %} - {% if user == profile or user.is_root or user.is_office %} + {% if user == profile or user.is_root or user.is_board_member %} {% trans subscription_end=get_subscriber(profile).subscriptions.last().subscription_end %}Subscribed until {{ subscription_end }}{% endtrans %}
{% trans %}Account number: {% endtrans %}{{ profile.customer.account_id }}
+ {% endif %} + {% if user == profile or user.is_root or user.is_board_member or user.is_launderette_manager %} {# Shows tokens bought by the user #} {{ show_tokens(profile) }} {# Shows slots took by the user #}