mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-04 02:53:06 +00:00 
			
		
		
		
	Fix for club tools
This commit is contained in:
		@@ -76,7 +76,7 @@ class Club(models.Model):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @cached_property
 | 
					    @cached_property
 | 
				
			||||||
    def president(self):
 | 
					    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):
 | 
					    def check_loop(self):
 | 
				
			||||||
        """Raise a validation error when a loop is found within the parent list"""
 | 
					        """Raise a validation error when a loop is found within the parent list"""
 | 
				
			||||||
@@ -128,12 +128,10 @@ class Club(models.Model):
 | 
				
			|||||||
                self.save()
 | 
					                self.save()
 | 
				
			||||||
        elif self.page and self.page.name != self.unix_name:
 | 
					        elif self.page and self.page.name != self.unix_name:
 | 
				
			||||||
            self.page.unset_lock()
 | 
					            self.page.unset_lock()
 | 
				
			||||||
            # self.page.set_lock(root)
 | 
					 | 
				
			||||||
            self.page.name = self.unix_name
 | 
					            self.page.name = self.unix_name
 | 
				
			||||||
            self.page.save(force_lock=True)
 | 
					            self.page.save(force_lock=True)
 | 
				
			||||||
        elif self.page and self.parent and self.parent.page and self.page.parent != self.parent.page:
 | 
					        elif self.page and self.parent and self.parent.page and self.page.parent != self.parent.page:
 | 
				
			||||||
            self.page.unset_lock()
 | 
					            self.page.unset_lock()
 | 
				
			||||||
            # self.page.set_lock(root)
 | 
					 | 
				
			||||||
            self.page.parent = self.parent.page
 | 
					            self.page.parent = self.parent.page
 | 
				
			||||||
            self.page.save(force_lock=True)
 | 
					            self.page.save(force_lock=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,10 +5,21 @@
 | 
				
			|||||||
{% endblock %}
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% macro display_club(club) -%}
 | 
					{% 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.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.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>
 | 
					        <ul>
 | 
				
			||||||
            {%- for c in club.children.order_by('name') %}
 | 
					            {%- for c in club.children.order_by('name') %}
 | 
				
			||||||
                {{ display_club(c) }}
 | 
					                {{ display_club(c) }}
 | 
				
			||||||
@@ -25,7 +36,7 @@
 | 
				
			|||||||
    {% if club_list %}
 | 
					    {% if club_list %}
 | 
				
			||||||
    <h3>{% trans %}Club list{% endtrans %}</h3>
 | 
					    <h3>{% trans %}Club list{% endtrans %}</h3>
 | 
				
			||||||
    <ul>
 | 
					    <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) }}
 | 
					        {{ display_club(c) }}
 | 
				
			||||||
        {%- endfor %}
 | 
					        {%- endfor %}
 | 
				
			||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,6 +26,10 @@ from django.db import connection, migrations
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PsqlRunOnly(migrations.RunSQL):
 | 
					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):
 | 
					    def _run_sql(self, schema_editor, sqls):
 | 
				
			||||||
        if connection.vendor == 'postgresql':
 | 
					        if connection.vendor == 'postgresql':
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,7 +26,7 @@
 | 
				
			|||||||
    <div class="tools">
 | 
					    <div class="tools">
 | 
				
			||||||
        {% if page %}
 | 
					        {% if page %}
 | 
				
			||||||
        {% if page.club %}
 | 
					        {% 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 %}
 | 
					        {% else %}
 | 
				
			||||||
        <a href="{{ url('core:page', page.get_full_name()) }}">{% trans %}View{% endtrans %}</a>
 | 
					        <a href="{{ url('core:page', page.get_full_name()) }}">{% trans %}View{% endtrans %}</a>
 | 
				
			||||||
        {% endif %}
 | 
					        {% endif %}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user