mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Add basic counter model
This commit is contained in:
@ -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",
|
||||
|
@ -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):
|
||||
|
@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user