Add basic counter model

This commit is contained in:
Skia
2016-03-28 14:54:35 +02:00
parent 7d7652e319
commit 21f1393097
17 changed files with 132 additions and 2 deletions

View File

@ -48,6 +48,7 @@ Welcome to the wiki page!
s.set_password("plop")
s.save()
s.view_groups=[settings.AE_GROUPS['members']['id']]
s.groups=[settings.AE_GROUPS['board']['id']]
s.save()
# Adding user Guy
u = User(username='guy', last_name="Carlier", first_name="Guy",

View File

@ -101,7 +101,7 @@ class User(AbstractBaseUser, PermissionsMixin):
if group_name == settings.AE_GROUPS['public']['name']:
return True
if group_name == settings.AE_GROUPS['members']['name']: # We check the subscription if asked
try:
try: # TODO: change for a test in settings.INSTALLED_APP
from subscription import Subscriber
s = Subscriber.objects.filter(pk=self.pk).first()
if s is not None and s.is_subscribed():
@ -110,6 +110,16 @@ class User(AbstractBaseUser, PermissionsMixin):
return False
except Exception as e:
print(e)
return False
if group_name[-6:] == "-board":
try: # TODO: change for a test in settings.INSTALLED_APP
from club.models import Club
name = group_name[:-6]
c = Club.objects.filter(unix_name=name).first()
return c.get_membership_for(self).role >= 2
except Exception as e:
print(e)
return False
return self.groups.filter(name=group_name).exists()
def get_profile(self):

View File

@ -14,6 +14,7 @@
{% endif %}
{% if user.is_in_group(settings.AE_GROUPS['root']['name']) or user.is_in_group(settings.AE_GROUPS['board']['name']) %}
<li><a href="{{ url('subscription:subscription') }}">Subscriptions</a></li>
<li><a href="{{ url('counter:list') }}">Counters management</a></li>
{% endif %}
</ul>