Nice club presentation

This commit is contained in:
Antoine Bartuccio 2017-09-19 16:27:48 +02:00
parent 790d723d08
commit db509bf060
Signed by: klmp200
GPG Key ID: E7245548C53F904B
6 changed files with 51 additions and 3 deletions

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('club', '0010_auto_20170912_2028'),
]
operations = [
migrations.AddField(
model_name='club',
name='short_description',
field=models.CharField(max_length=1000, verbose_name='short description', blank=True),
),
]

View File

@ -32,6 +32,7 @@ from django.db import transaction
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.utils import timezone from django.utils import timezone
from django.core.validators import RegexValidator, validate_email from django.core.validators import RegexValidator, validate_email
from django.utils.functional import cached_property
from core.models import User, MetaGroup, Group, SithFile, RealGroup, Notification, Page from core.models import User, MetaGroup, Group, SithFile, RealGroup, Notification, Page
@ -59,6 +60,7 @@ class Club(models.Model):
) )
logo = models.ImageField(upload_to='club_logos', verbose_name=_('logo'), null=True, blank=True) logo = models.ImageField(upload_to='club_logos', verbose_name=_('logo'), null=True, blank=True)
is_active = models.BooleanField(_('is active'), default=True) is_active = models.BooleanField(_('is active'), default=True)
short_description = models.CharField(_('short description'), max_length=1000, blank=True)
address = models.CharField(_('address'), max_length=254) address = models.CharField(_('address'), max_length=254)
# email = models.EmailField(_('email address'), unique=True) # This should, and will be generated automatically # email = models.EmailField(_('email address'), unique=True) # This should, and will be generated automatically
owner_group = models.ForeignKey(Group, related_name="owned_club", owner_group = models.ForeignKey(Group, related_name="owned_club",
@ -72,6 +74,10 @@ class Club(models.Model):
class Meta: class Meta:
ordering = ['name', 'unix_name'] ordering = ['name', 'unix_name']
@cached_property
def president(self):
return self.members.filter(role=settings.SITH_CLUB_ROLES_ID['President'], start_date__lte=timezone.now()).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"""
objs = [] objs = []

View File

@ -6,7 +6,9 @@
{% macro display_club(club) -%} {% macro display_club(club) -%}
<li><a href="{{ url('club:club_view', club_id=club.id) }}">{{ club.name }}</a> <li><a href="{{ url('club:club_view', club_id=club.id) }}">{{ club.name }}</a>
{%- if club.children.all()|length != 0 %} {% 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 %}
<ul> <ul>
{%- for c in club.children.order_by('name') %} {%- for c in club.children.order_by('name') %}
{{ display_club(c) }} {{ display_club(c) }}
@ -23,7 +25,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.order_by('name') if c.parent is none %} {%- for c in club_list.exclude(is_active=False).order_by('name') if c.parent is none %}
{{ display_club(c) }} {{ display_club(c) }}
{%- endfor %} {%- endfor %}
</ul> </ul>

View File

@ -343,7 +343,7 @@ class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView):
""" """
model = Club model = Club
pk_url_kwarg = "club_id" pk_url_kwarg = "club_id"
fields = ['address', 'logo'] fields = ['address', 'logo', 'short_description']
template_name = 'core/edit.jinja' template_name = 'core/edit.jinja'
current_tab = "edit" current_tab = "edit"

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
('core', '0024_auto_20170906_1317'),
]
operations = [
migrations.AlterField(
model_name='page',
name='name',
field=models.CharField(max_length=30, verbose_name='page unix name', validators=[django.core.validators.RegexValidator('^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$', 'Enter a valid page name. This value may contain only unaccented letters, numbers and ./+/-/_ characters.')]),
),
]

View File

@ -150,6 +150,7 @@
{% if not popup %} {% if not popup %}
<nav> <nav>
<a href="{{ url('core:index') }}">{% trans %}Main{% endtrans %}</a> <a href="{{ url('core:index') }}">{% trans %}Main{% endtrans %}</a>
<a href="{{ url('core:page', page_name='clubs') }}">{% trans %}Clubs{% endtrans %}</a>
<a href="{{ url('matmat:search_clear') }}">{% trans %}Matmatronch{% endtrans %}</a> <a href="{{ url('matmat:search_clear') }}">{% trans %}Matmatronch{% endtrans %}</a>
<a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a> <a href="{{ url('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a> <a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>