Some com templates improvments and reordering some models

This commit is contained in:
Skia
2017-03-24 09:19:15 +01:00
parent d2da5716ba
commit 39b32d456c
10 changed files with 94 additions and 6 deletions

View File

@ -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)

View File

@ -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>

View File

@ -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'),

View File

@ -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"