mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
@ -120,10 +120,7 @@ class Command(BaseCommand):
|
||||
club_root = SithFile.objects.create(name="clubs", owner=root)
|
||||
sas = SithFile.objects.create(name="SAS", owner=root)
|
||||
main_club = Club.objects.create(
|
||||
id=1,
|
||||
name=settings.SITH_MAIN_CLUB["name"],
|
||||
unix_name=settings.SITH_MAIN_CLUB["unix_name"],
|
||||
address=settings.SITH_MAIN_CLUB["address"],
|
||||
id=1, name="AE", address="6 Boulevard Anatole France, 90000 Belfort"
|
||||
)
|
||||
main_club.board_group.permissions.add(
|
||||
*Permission.objects.filter(
|
||||
@ -131,16 +128,14 @@ class Command(BaseCommand):
|
||||
)
|
||||
)
|
||||
bar_club = Club.objects.create(
|
||||
id=2,
|
||||
name=settings.SITH_BAR_MANAGER["name"],
|
||||
unix_name=settings.SITH_BAR_MANAGER["unix_name"],
|
||||
address=settings.SITH_BAR_MANAGER["address"],
|
||||
id=settings.SITH_PDF_CLUB_ID,
|
||||
name="PdF",
|
||||
address="6 Boulevard Anatole France, 90000 Belfort",
|
||||
)
|
||||
Club.objects.create(
|
||||
id=84,
|
||||
name=settings.SITH_LAUNDERETTE_MANAGER["name"],
|
||||
unix_name=settings.SITH_LAUNDERETTE_MANAGER["unix_name"],
|
||||
address=settings.SITH_LAUNDERETTE_MANAGER["address"],
|
||||
id=settings.SITH_LAUNDERETTE_CLUB_ID,
|
||||
name="Laverie",
|
||||
address="6 Boulevard Anatole France, 90000 Belfort",
|
||||
)
|
||||
|
||||
self.reset_index("club")
|
||||
@ -353,31 +348,17 @@ Welcome to the wiki page!
|
||||
|
||||
# Clubs
|
||||
Club.objects.create(
|
||||
name="Bibo'UT",
|
||||
unix_name="bibout",
|
||||
address="46 de la Boustifaille",
|
||||
parent=main_club,
|
||||
name="Bibo'UT", address="46 de la Boustifaille", parent=main_club
|
||||
)
|
||||
guyut = Club.objects.create(
|
||||
name="Guy'UT",
|
||||
unix_name="guyut",
|
||||
address="42 de la Boustifaille",
|
||||
parent=main_club,
|
||||
)
|
||||
Club.objects.create(
|
||||
name="Woenzel'UT", unix_name="woenzel", address="Woenzel", parent=guyut
|
||||
name="Guy'UT", address="42 de la Boustifaille", parent=main_club
|
||||
)
|
||||
Club.objects.create(name="Woenzel'UT", address="Woenzel", parent=guyut)
|
||||
troll = Club.objects.create(
|
||||
name="Troll Penché",
|
||||
unix_name="troll",
|
||||
address="Terre Du Milieu",
|
||||
parent=main_club,
|
||||
name="Troll Penché", address="Terre Du Milieu", parent=main_club
|
||||
)
|
||||
refound = Club.objects.create(
|
||||
name="Carte AE",
|
||||
unix_name="carte_ae",
|
||||
address="Jamais imprimée",
|
||||
parent=main_club,
|
||||
name="Carte AE", address="Jamais imprimée", parent=main_club
|
||||
)
|
||||
|
||||
Membership.objects.create(user=skia, club=main_club, role=3)
|
||||
|
@ -64,12 +64,12 @@ class Command(BaseCommand):
|
||||
)
|
||||
)
|
||||
self.make_club(
|
||||
Club.objects.get(unix_name="ae"),
|
||||
Club.objects.get(id=settings.SITH_MAIN_CLUB_ID),
|
||||
random.sample(subscribers_now, k=min(30, len(subscribers_now))),
|
||||
random.sample(old_subscribers, k=min(60, len(old_subscribers))),
|
||||
)
|
||||
self.make_club(
|
||||
Club.objects.get(unix_name="troll"),
|
||||
Club.objects.get(name="Troll Penché"),
|
||||
random.sample(subscribers_now, k=min(20, len(subscribers_now))),
|
||||
random.sample(old_subscribers, k=min(80, len(old_subscribers))),
|
||||
)
|
||||
@ -235,7 +235,7 @@ class Command(BaseCommand):
|
||||
categories = list(
|
||||
ProductType.objects.filter(name__in=[c.name for c in categories])
|
||||
)
|
||||
ae = Club.objects.get(unix_name="ae")
|
||||
ae = Club.objects.get(id=settings.SITH_MAIN_CLUB_ID)
|
||||
other_clubs = random.sample(list(Club.objects.all()), k=3)
|
||||
groups = list(
|
||||
Group.objects.filter(name__in=["Subscribers", "Old subscribers", "Public"])
|
||||
|
@ -421,13 +421,9 @@ class User(AbstractUser):
|
||||
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)
|
||||
)
|
||||
return Club.objects.get(
|
||||
id=settings.SITH_LAUNDERETTE_CLUB_ID
|
||||
).get_membership_for(self)
|
||||
|
||||
@cached_property
|
||||
def is_banned_alcohol(self) -> bool:
|
||||
|
@ -132,111 +132,104 @@
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{% if
|
||||
user == profile
|
||||
or user.memberships.ongoing().exists()
|
||||
or user.is_board_member
|
||||
or user.is_in_group(name=settings.SITH_BAR_MANAGER_BOARD_GROUP)
|
||||
%}
|
||||
{# if the user is member of a club, he can view the subscription state #}
|
||||
<hr>
|
||||
{% if profile.is_subscribed %}
|
||||
{% if user == profile or user.is_root or user.is_board_member %}
|
||||
<div>
|
||||
{{ user_subscription(profile) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if user == profile or user.is_root or user.is_board_member or user.is_launderette_manager %}
|
||||
<div>
|
||||
{# Shows tokens bought by the user #}
|
||||
{{ show_tokens(profile) }}
|
||||
{# Shows slots took by the user #}
|
||||
{{ show_slots(profile) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div>
|
||||
{% trans %}Not subscribed{% endtrans %}
|
||||
{% if user.is_board_member %}
|
||||
<a href="{{ url('subscription:subscription') }}?member={{ profile.id }}">
|
||||
{% trans %}New subscription{% endtrans %}
|
||||
</a>
|
||||
{% if user == profile or user.memberships.ongoing().exists() %}
|
||||
{# if the user is member of a club, he can view the subscription state #}
|
||||
<hr>
|
||||
{% if profile.is_subscribed %}
|
||||
{% if user == profile or user.is_root or user.is_board_member %}
|
||||
<div>
|
||||
{{ user_subscription(profile) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if user == profile or user.is_root or user.is_board_member or user.is_launderette_manager %}
|
||||
<div>
|
||||
{{ show_tokens(profile) }}
|
||||
{{ show_slots(profile) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div>
|
||||
{% trans %}Not subscribed{% endtrans %}
|
||||
{% if user.is_board_member %}
|
||||
<a href="{{ url('subscription:subscription') }}?member={{ profile.id }}">
|
||||
{% trans %}New subscription{% endtrans %}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<br>
|
||||
{% if profile.was_subscribed and (user == profile or user.has_perm("subscription.view_subscription")) %}
|
||||
<div class="collapse" :class="{'shadow': collapsed}" x-data="{collapsed: false}" x-cloak>
|
||||
<div class="collapse-header clickable" @click="collapsed = !collapsed">
|
||||
<span class="collapse-header-text">
|
||||
{% trans %}Subscription history{% endtrans %}
|
||||
</span>
|
||||
<span class="collapse-header-icon" :class="{'reverse': collapsed}">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="collapse-body" x-show="collapsed" x-transition.scale.origin.top>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans %}Subscription start{% endtrans %}</th>
|
||||
<th>{% trans %}Subscription end{% endtrans %}</th>
|
||||
<th>{% trans %}Subscription type{% endtrans %}</th>
|
||||
<th>{% trans %}Payment method{% endtrans %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for sub in profile.subscriptions.all() %}
|
||||
<tr>
|
||||
<td>{{ sub.subscription_start }}</td>
|
||||
<td>{{ sub.subscription_end }}</td>
|
||||
<td>{{ sub.subscription_type }}</td>
|
||||
<td>{{ sub.get_payment_method_display() }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
{% endif %}
|
||||
|
||||
<div>
|
||||
{% if user.is_root or user.is_board_member %}
|
||||
<form class="form-gifts" action="{{ url('core:user_gift_create', user_id=profile.id) }}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ gift_form.label }}
|
||||
{{ gift_form.user }}
|
||||
<input type="submit" value="{% trans %}Give gift{% endtrans %}">
|
||||
</form>
|
||||
{% if profile.gifts.exists() %}
|
||||
{% set gifts = profile.gifts.order_by("-date")|list %}
|
||||
<br>
|
||||
<br>
|
||||
{% if profile.was_subscribed and (user == profile or user.has_perm("subscription.view_subscription")) %}
|
||||
<div class="collapse" :class="{'shadow': collapsed}" x-data="{collapsed: false}" x-cloak>
|
||||
<div class="collapse-header clickable" @click="collapsed = !collapsed">
|
||||
<span class="collapse-header-text">
|
||||
{% trans %}Last given gift :{% endtrans %} {{ gifts[0] }}
|
||||
{% trans %}Subscription history{% endtrans %}
|
||||
</span>
|
||||
<span class="collapse-header-icon" :class="{'reverse': collapsed}">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="collapse-body" x-show="collapsed" x-transition.scale.origin.top>
|
||||
<ul>
|
||||
{% for gift in gifts %}
|
||||
<li>{{ gift }}
|
||||
<a href="{{ url('core:user_gift_delete', user_id=profile.id, gift_id=gift.id) }}">
|
||||
<i class="fa-solid fa-trash-can delete-action"></i>
|
||||
</a>
|
||||
</li>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans %}Subscription start{% endtrans %}</th>
|
||||
<th>{% trans %}Subscription end{% endtrans %}</th>
|
||||
<th>{% trans %}Subscription type{% endtrans %}</th>
|
||||
<th>{% trans %}Payment method{% endtrans %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for sub in profile.subscriptions.all() %}
|
||||
<tr>
|
||||
<td>{{ sub.subscription_start }}</td>
|
||||
<td>{{ sub.subscription_end }}</td>
|
||||
<td>{{ sub.subscription_type }}</td>
|
||||
<td>{{ sub.get_payment_method_display() }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<em>{% trans %}No gift given yet{% endtrans %}</em>
|
||||
</div>
|
||||
<hr>
|
||||
{% endif %}
|
||||
|
||||
<div>
|
||||
{% if user.is_root or user.is_board_member %}
|
||||
<form class="form-gifts" action="{{ url('core:user_gift_create', user_id=profile.id) }}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ gift_form.label }}
|
||||
{{ gift_form.user }}
|
||||
<input type="submit" value="{% trans %}Give gift{% endtrans %}">
|
||||
</form>
|
||||
{% if profile.gifts.exists() %}
|
||||
{% set gifts = profile.gifts.order_by("-date")|list %}
|
||||
<br>
|
||||
<div class="collapse" :class="{'shadow': collapsed}" x-data="{collapsed: false}" x-cloak>
|
||||
<div class="collapse-header clickable" @click="collapsed = !collapsed">
|
||||
<span class="collapse-header-text">
|
||||
{% trans %}Last given gift :{% endtrans %} {{ gifts[0] }}
|
||||
</span>
|
||||
<span class="collapse-header-icon" :class="{'reverse': collapsed}">
|
||||
<i class="fa fa-caret-down"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="collapse-body" x-show="collapsed" x-transition.scale.origin.top>
|
||||
<ul>
|
||||
{% for gift in gifts %}
|
||||
<li>{{ gift }}
|
||||
<a href="{{ url('core:user_gift_delete', user_id=profile.id, gift_id=gift.id) }}">
|
||||
<i class="fa-solid fa-trash-can delete-action"></i>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<em>{% trans %}No gift given yet{% endtrans %}</em>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -243,17 +243,7 @@ class UserTabsMixin(TabedViewMixin):
|
||||
if (
|
||||
hasattr(user, "customer")
|
||||
and user.customer
|
||||
and (
|
||||
user == self.request.user
|
||||
or self.request.user.is_in_group(
|
||||
pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID
|
||||
)
|
||||
or self.request.user.is_in_group(
|
||||
name=settings.SITH_BAR_MANAGER["unix_name"]
|
||||
+ settings.SITH_BOARD_SUFFIX
|
||||
)
|
||||
or self.request.user.is_root
|
||||
)
|
||||
and (user == self.request.user or user.has_perm("counter.view_customer"))
|
||||
):
|
||||
tab_list.append(
|
||||
{
|
||||
@ -362,12 +352,7 @@ class UserStatsView(UserTabsMixin, CanViewMixin, DetailView):
|
||||
raise Http404
|
||||
|
||||
if not (
|
||||
profile == request.user
|
||||
or request.user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)
|
||||
or request.user.is_in_group(
|
||||
name=settings.SITH_BAR_MANAGER["unix_name"] + settings.SITH_BOARD_SUFFIX
|
||||
)
|
||||
or request.user.is_root
|
||||
profile == request.user or request.user.has_perm("counter.view_customer")
|
||||
):
|
||||
raise PermissionDenied
|
||||
|
||||
@ -591,14 +576,9 @@ class UserAccountBase(UserTabsMixin, DetailView):
|
||||
current_tab = "account"
|
||||
queryset = User.objects.select_related("customer")
|
||||
|
||||
def dispatch(self, request, *arg, **kwargs): # Manually validates the rights
|
||||
if (
|
||||
kwargs.get("user_id") == request.user.id
|
||||
or request.user.is_in_group(pk=settings.SITH_GROUP_ACCOUNTING_ADMIN_ID)
|
||||
or request.user.is_in_group(
|
||||
name=settings.SITH_BAR_MANAGER["unix_name"] + settings.SITH_BOARD_SUFFIX
|
||||
)
|
||||
or request.user.is_root
|
||||
def dispatch(self, request, *arg, **kwargs):
|
||||
if kwargs.get("user_id") == request.user.id or request.user.has_perm(
|
||||
"counter.view_customer"
|
||||
):
|
||||
return super().dispatch(request, *arg, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
Reference in New Issue
Block a user