mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Fix for club tools
This commit is contained in:
parent
4026d076b3
commit
2c1cf2d7af
@ -76,7 +76,7 @@ class Club(models.Model):
|
||||
|
||||
@cached_property
|
||||
def president(self):
|
||||
return self.members.filter(role=settings.SITH_CLUB_ROLES_ID['President'], start_date__lte=timezone.now()).first()
|
||||
return self.members.filter(role=settings.SITH_CLUB_ROLES_ID['President'], end_date=None).first()
|
||||
|
||||
def check_loop(self):
|
||||
"""Raise a validation error when a loop is found within the parent list"""
|
||||
@ -128,12 +128,10 @@ class Club(models.Model):
|
||||
self.save()
|
||||
elif self.page and self.page.name != self.unix_name:
|
||||
self.page.unset_lock()
|
||||
# self.page.set_lock(root)
|
||||
self.page.name = self.unix_name
|
||||
self.page.save(force_lock=True)
|
||||
elif self.page and self.parent and self.parent.page and self.page.parent != self.parent.page:
|
||||
self.page.unset_lock()
|
||||
# self.page.set_lock(root)
|
||||
self.page.parent = self.parent.page
|
||||
self.page.save(force_lock=True)
|
||||
|
||||
|
@ -5,10 +5,21 @@
|
||||
{% endblock %}
|
||||
|
||||
{% macro display_club(club) -%}
|
||||
<li><a href="{{ url('club:club_view', club_id=club.id) }}">{{ club.name }}</a>
|
||||
|
||||
{% if club.is_active or user.is_root %}
|
||||
|
||||
<li><a href="{{ url('club:club_view', club_id=club.id) }}">{{ club.name }}</a>
|
||||
|
||||
{% if not club.is_active %}
|
||||
({% trans %}inactive{% endtrans %})
|
||||
{% endif %}
|
||||
|
||||
{% if club.president %} - <a href="{{ url('core:user_profile', user_id=club.president.user.id) }}">{{ club.president.user }}</a>{% endif %}
|
||||
{% if club.short_description %}<p>{{ club.short_description|markdown }}</p>{% endif %}
|
||||
{%- if club.children.exclude(is_active=False).all()|length != 0 %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{%- if club.children.all()|length != 0 %}
|
||||
<ul>
|
||||
{%- for c in club.children.order_by('name') %}
|
||||
{{ display_club(c) }}
|
||||
@ -25,7 +36,7 @@
|
||||
{% if club_list %}
|
||||
<h3>{% trans %}Club list{% endtrans %}</h3>
|
||||
<ul>
|
||||
{%- for c in club_list.exclude(is_active=False).order_by('name') if c.parent is none %}
|
||||
{%- for c in club_list.all().order_by('name') if c.parent is none %}
|
||||
{{ display_club(c) }}
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
|
@ -26,6 +26,10 @@ from django.db import connection, migrations
|
||||
|
||||
|
||||
class PsqlRunOnly(migrations.RunSQL):
|
||||
"""
|
||||
Usefull for migrations with specific postgresql commands
|
||||
Avoid breaking tests and local dev environnment
|
||||
"""
|
||||
|
||||
def _run_sql(self, schema_editor, sqls):
|
||||
if connection.vendor == 'postgresql':
|
||||
|
@ -26,7 +26,7 @@
|
||||
<div class="tools">
|
||||
{% if page %}
|
||||
{% if page.club %}
|
||||
<a href="{{ url('club:club_view', club_id=page.club.id) }}">{% trans %}View{% endtrans %}</a>
|
||||
<a href="{{ url('club:club_view', club_id=page.club.id) }}">{% trans %}Infos{% endtrans %}</a>
|
||||
{% else %}
|
||||
<a href="{{ url('core:page', page.get_full_name()) }}">{% trans %}View{% endtrans %}</a>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user