Verified Commit db509bf0 authored by Sli's avatar Sli
Browse files

Nice club presentation

parent 790d723d
# -*- 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),
),
]
......@@ -32,6 +32,7 @@ from django.db import transaction
from django.core.urlresolvers import reverse
from django.utils import timezone
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
......@@ -59,6 +60,7 @@ class Club(models.Model):
)
logo = models.ImageField(upload_to='club_logos', verbose_name=_('logo'), null=True, blank=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)
# email = models.EmailField(_('email address'), unique=True) # This should, and will be generated automatically
owner_group = models.ForeignKey(Group, related_name="owned_club",
......@@ -72,6 +74,10 @@ class Club(models.Model):
class Meta:
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):
"""Raise a validation error when a loop is found within the parent list"""
objs = []
......
......@@ -6,7 +6,9 @@
{% macro display_club(club) -%}
<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>
{%- for c in club.children.order_by('name') %}
{{ display_club(c) }}
......@@ -23,7 +25,7 @@
{% if club_list %}
<h3>{% trans %}Club list{% endtrans %}</h3>
<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) }}
{%- endfor %}
</ul>
......
......@@ -343,7 +343,7 @@ class ClubEditView(ClubTabsMixin, CanEditMixin, UpdateView):
"""
model = Club
pk_url_kwarg = "club_id"
fields = ['address', 'logo']
fields = ['address', 'logo', 'short_description']
template_name = 'core/edit.jinja'
current_tab = "edit"
......
# -*- 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.')]),
),
]
......@@ -150,6 +150,7 @@
{% if not popup %}
<nav>
<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('core:page', page_name="Index") }}">{% trans %}Wiki{% endtrans %}</a>
<a href="{{ url('sas:main') }}">{% trans %}SAS{% endtrans %}</a>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment