mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +00:00
Some various forum fixes and improvements
This commit is contained in:
parent
d6b5db4a4b
commit
f262014f9b
@ -7,7 +7,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<a href="{{ url('forum:main') }}">Forum</a>
|
||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||
{% for f in forum.get_parent_list() %}
|
||||
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
|
||||
{% endfor %}
|
||||
@ -16,9 +16,9 @@
|
||||
<h3>{{ forum.name }}</h3>
|
||||
<p>
|
||||
{% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
|
||||
<a href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">New forum</a> <br/>
|
||||
<a href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">{% trans %}New forum{% endtrans %}</a> <br/>
|
||||
{% endif %}
|
||||
<a href="{{ url('forum:new_topic', forum_id=forum.id) }}">New topic</a>
|
||||
<a href="{{ url('forum:new_topic', forum_id=forum.id) }}">{% trans %}New topic{% endtrans %}</a>
|
||||
</p>
|
||||
{% for f in forum.children.all() %}
|
||||
{{ display_forum(f, user) }}
|
||||
|
@ -16,8 +16,8 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if user.is_owner(forum) %}
|
||||
<a class="ib" href="{{ url('forum:edit_forum', forum_id=forum.id) }}">Edit</a>
|
||||
<a class="ib" href="{{ url('forum:delete_forum', forum_id=forum.id) }}">Delete</a>
|
||||
<a class="ib" href="{{ url('forum:edit_forum', forum_id=forum.id) }}">{% trans %}Edit{% endtrans %}</a>
|
||||
<a class="ib" href="{{ url('forum:delete_forum', forum_id=forum.id) }}">{% trans %}Delete{% endtrans %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not forum.is_category %}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
<a href="{{ url('forum:main') }}">Forum</a> >
|
||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a> >
|
||||
</p>
|
||||
<h3>{% trans %}Forum{% endtrans %}</h3>
|
||||
<p>
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
<a href="{{ url('forum:main') }}">Forum</a>
|
||||
<a href="{{ url('forum:main') }}">{% trans %}Forum{% endtrans %}</a>
|
||||
{% for f in topic.forum.get_parent_list() %}
|
||||
> <a href="{{ f.get_absolute_url() }}">{{ f }}</a>
|
||||
{% endfor %}
|
||||
@ -52,7 +52,8 @@
|
||||
<br/>
|
||||
<strong>{{ user_profile_link(m.author) }}</strong>
|
||||
</div>
|
||||
<div {% if m.id == first_unread_message_id %}id="first_unread"{% endif %} style="display: inline-block; width: 80%; vertical-align: top;">
|
||||
<div {% if m.id == first_unread_message_id %}id="first_unread"{% endif %} style="display: inline-block; width:
|
||||
80%; vertical-align: top; {% if m.deleted %}background: #FFAAAA;{% endif %}">
|
||||
<div style="display: inline-block; width: 74%;">
|
||||
{% if m.title %}
|
||||
<h5>{{ m.title }}</h5>
|
||||
|
@ -10,7 +10,7 @@ from django import forms
|
||||
from django.db import models
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
import math
|
||||
from ajax_select import make_ajax_form, make_ajax_field
|
||||
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, TabedViewMixin
|
||||
from forum.models import Forum, ForumMessage, ForumTopic, ForumMessageMeta
|
||||
@ -40,9 +40,16 @@ class ForumLastUnread(ListView):
|
||||
date__gt=self.request.user.forum_infos.last_read_date).values_list('topic') # TODO try to do better
|
||||
return self.model.objects.filter(id__in=l).annotate(models.Max('messages__date')).order_by('-messages__date__max').select_related('author')
|
||||
|
||||
class ForumForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Forum
|
||||
fields = ['name', 'parent', 'owner_club', 'is_category', 'edit_groups', 'view_groups']
|
||||
edit_groups = make_ajax_field(Forum, 'edit_groups', 'groups', help_text="")
|
||||
view_groups = make_ajax_field(Forum, 'view_groups', 'groups', help_text="")
|
||||
|
||||
class ForumCreateView(CanCreateMixin, CreateView):
|
||||
model = Forum
|
||||
fields = ['name', 'parent', 'owner_club', 'is_category', 'edit_groups', 'view_groups']
|
||||
form_class = ForumForm
|
||||
template_name = "core/create.jinja"
|
||||
|
||||
def get_initial(self):
|
||||
@ -54,10 +61,7 @@ class ForumCreateView(CanCreateMixin, CreateView):
|
||||
except: pass
|
||||
return init
|
||||
|
||||
class ForumEditForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Forum
|
||||
fields = ['name', 'parent', 'owner_club', 'is_category', 'edit_groups', 'view_groups']
|
||||
class ForumEditForm(ForumForm):
|
||||
recursive = forms.BooleanField(label=_("Apply rights and club owner recursively"), required=False)
|
||||
|
||||
class ForumEditView(CanEditPropMixin, UpdateView):
|
||||
@ -126,7 +130,7 @@ class ForumTopicDetailView(CanViewMixin, DetailView):
|
||||
try:
|
||||
kwargs['first_unread_message_id'] = msg.id
|
||||
except:
|
||||
kwargs['first_unread_message_id'] = math.inf
|
||||
kwargs['first_unread_message_id'] = float("inf")
|
||||
return kwargs
|
||||
|
||||
class ForumMessageEditView(CanEditMixin, UpdateView):
|
||||
|
Loading…
Reference in New Issue
Block a user