mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Some com templates improvments and reordering some models
This commit is contained in:
parent
d2da5716ba
commit
39b32d456c
19
accounting/migrations/0005_auto_20170324_0917.py
Normal file
19
accounting/migrations/0005_auto_20170324_0917.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounting', '0004_auto_20161005_1505'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='operation',
|
||||
name='remark',
|
||||
field=models.CharField(null=True, max_length=128, blank=True, verbose_name='comment'),
|
||||
),
|
||||
]
|
18
club/migrations/0007_auto_20170324_0917.py
Normal file
18
club/migrations/0007_auto_20170324_0917.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('club', '0006_auto_20161229_0040'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='club',
|
||||
options={'ordering': ['name', 'unix_name']},
|
||||
),
|
||||
]
|
@ -38,6 +38,9 @@ class Club(models.Model):
|
||||
home = models.OneToOneField(SithFile, related_name='home_of_club', verbose_name=_("home"), null=True, blank=True,
|
||||
on_delete=models.SET_NULL)
|
||||
|
||||
class Meta:
|
||||
ordering = ['name', 'unix_name']
|
||||
|
||||
def check_loop(self):
|
||||
"""Raise a validation error when a loop is found within the parent list"""
|
||||
objs = []
|
||||
|
@ -125,3 +125,5 @@ class WeekmailArticle(models.Model):
|
||||
def is_owned_by(self, user):
|
||||
return user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
||||
|
||||
def __str__(self):
|
||||
return "%s - %s (%s)" % (self.title, self.author, self.club)
|
||||
|
@ -9,6 +9,7 @@
|
||||
<h3>{% trans %}Weekmail{% endtrans %} {{ object.id }}</h3>
|
||||
<p><a href="{{ url('com:weekmail_preview') }}">{% trans %}Preview{% endtrans %}</a></p>
|
||||
<p><a href="{{ url('com:weekmail_preview') }}?send=true">{% trans %}Send{% endtrans %}</a></p>
|
||||
<p><a href="{{ url('com:weekmail_article') }}">{% trans %}New article{% endtrans %}</a></p>
|
||||
<h4>{% trans %}Articles in no weekmail yet{% endtrans %}</h4>
|
||||
<table>
|
||||
<thead>
|
||||
@ -27,7 +28,13 @@
|
||||
<td><a href="{{ a.club.get_absolute_url() }}">{{ a.club }}</a></td>
|
||||
<td>{{ a.title }}</td>
|
||||
<td>{{ a.content|markdown }}</td>
|
||||
<td><a href="?add_article={{ a.id }}">{% trans %}Add to weekmail{% endtrans %}</a></td>
|
||||
<td>
|
||||
<a href="{{ url('com:weekmail_article_edit', article_id=a.id) }}">{% trans %}Edit{% endtrans %}</a> |
|
||||
<a href="{{ url('com:weekmail_article_delete', article_id=a.id) }}">{% trans %}Delete{% endtrans %}</a> |
|
||||
<a href="?add_article={{ a.id }}">{% trans %}Add to weekmail{% endtrans %}</a> |
|
||||
<a href="?up_article={{ a.id }}">{% trans %}Up{% endtrans %}</a> |
|
||||
<a href="?down_article={{ a.id }}">{% trans %}Down{% endtrans %}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -52,6 +59,7 @@
|
||||
<td>{{ a.content|markdown }}</td>
|
||||
<td>
|
||||
<a href="{{ url('com:weekmail_article_edit', article_id=a.id) }}">{% trans %}Edit{% endtrans %}</a> |
|
||||
<a href="{{ url('com:weekmail_article_delete', article_id=a.id) }}">{% trans %}Delete{% endtrans %}</a> |
|
||||
<a href="?del_article={{ a.id }}">{% trans %}Delete from weekmail{% endtrans %}</a> |
|
||||
<a href="?up_article={{ a.id }}">{% trans %}Up{% endtrans %}</a> |
|
||||
<a href="?down_article={{ a.id }}">{% trans %}Down{% endtrans %}</a>
|
||||
|
@ -9,7 +9,7 @@ urlpatterns = [
|
||||
url(r'^sith/edit/weekmail_destinations$', WeekmailDestinationEditView.as_view(), name='weekmail_destinations'),
|
||||
url(r'^weekmail$', WeekmailEditView.as_view(), name='weekmail'),
|
||||
url(r'^weekmail/preview$', WeekmailPreviewView.as_view(), name='weekmail_preview'),
|
||||
url(r'^weekmail/club/(?P<club_id>[0-9]+)/new_article$', WeekmailArticleCreateView.as_view(), name='weekmail_article'),
|
||||
url(r'^weekmail/club/((?P<club_id>[0-9]+)/)?new_article$', WeekmailArticleCreateView.as_view(), name='weekmail_article'),
|
||||
url(r'^weekmail/article/(?P<article_id>[0-9]+)/delete$', WeekmailArticleDeleteView.as_view(), name='weekmail_article_delete'),
|
||||
url(r'^weekmail/article/(?P<article_id>[0-9]+)/edit$', WeekmailArticleEditView.as_view(), name='weekmail_article_edit'),
|
||||
url(r'^news$', NewsListView.as_view(), name='news_list'),
|
||||
|
16
com/views.py
16
com/views.py
@ -315,7 +315,7 @@ class WeekmailEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateVi
|
||||
class WeekmailArticleEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, UpdateView):
|
||||
"""Edit an article"""
|
||||
model = WeekmailArticle
|
||||
fields = ['title', 'content']
|
||||
fields = ['title', 'club', 'content']
|
||||
pk_url_kwarg = "article_id"
|
||||
template_name = 'core/edit.jinja'
|
||||
success_url = reverse_lazy('com:weekmail')
|
||||
@ -325,14 +325,21 @@ class WeekmailArticleEditView(ComTabsMixin, QuickNotifMixin, CanEditPropMixin, U
|
||||
class WeekmailArticleCreateView(QuickNotifMixin, CreateView): #XXX need to protect this view
|
||||
"""Post an article"""
|
||||
model = WeekmailArticle
|
||||
fields = ['title', 'content']
|
||||
fields = ['title', 'club', 'content']
|
||||
template_name = 'core/create.jinja'
|
||||
success_url = reverse_lazy('core:user_tools')
|
||||
quick_notif_url_arg = "qn_weekmail_new_article"
|
||||
|
||||
def get_initial(self):
|
||||
init = {}
|
||||
try:
|
||||
init['club'] = Club.objects.filter(id=self.kwargs['club_id']).first()
|
||||
except: pass
|
||||
return init
|
||||
|
||||
def form_valid(self, form):
|
||||
club = get_object_or_404(Club, id=self.kwargs['club_id'])
|
||||
form.instance.club = club
|
||||
# club = get_object_or_404(Club, id=self.kwargs['club_id'])
|
||||
# form.instance.club = club
|
||||
form.instance.author = self.request.user
|
||||
return super(WeekmailArticleCreateView, self).form_valid(form)
|
||||
|
||||
@ -340,6 +347,7 @@ class WeekmailArticleDeleteView(CanEditPropMixin, DeleteView):
|
||||
"""Delete an article"""
|
||||
model = WeekmailArticle
|
||||
template_name = 'core/delete_confirm.jinja'
|
||||
pk_url_kwarg = "article_id"
|
||||
|
||||
|
||||
|
||||
|
24
core/migrations/0020_auto_20170324_0917.py
Normal file
24
core/migrations/0020_auto_20170324_0917.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.core.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0019_preferences_receive_weekmail'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='group',
|
||||
options={'ordering': ['name']},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='page',
|
||||
name='name',
|
||||
field=models.CharField(validators=[django.core.validators.RegexValidator('^[A-z.+-]+$', 'Enter a valid page name. This value may contain only unaccented letters, numbers and ./+/-/_ characters.')], max_length=30, verbose_name='page unix name'),
|
||||
),
|
||||
]
|
@ -33,6 +33,10 @@ class Group(AuthGroup):
|
||||
help_text=_('Whether a group is a meta group or not'),
|
||||
)
|
||||
description = models.CharField(_('description'), max_length=60)
|
||||
|
||||
class Meta:
|
||||
ordering = ['name']
|
||||
|
||||
def get_absolute_url(self):
|
||||
"""
|
||||
This is needed for black magic powered UpdateView's children
|
||||
|
@ -66,8 +66,10 @@
|
||||
<h4>{% trans %}Communication{% endtrans %}</h4>
|
||||
<ul>
|
||||
{% if user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.is_root %}
|
||||
<li><a href="{{ url('com:weekmail_article') }}">{% trans %}Create weekmail article{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('com:weekmail') }}">{% trans %}Weekmail{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('com:weekmail_destinations') }}">{% trans %}Weekmail destinations{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('com:news_new') }}">{% trans %}Create news{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('com:news_admin_list') }}">{% trans %}Moderate news{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('com:index_edit') }}">{% trans %}Edit index page{% endtrans %}</a></li>
|
||||
<li><a href="{{ url('com:alert_edit') }}">{% trans %}Edit alert message{% endtrans %}</a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user