Mise à jour d'avril (#643)

This commit is contained in:
Julien Constant
2023-05-10 11:56:33 +02:00
committed by GitHub
parent 910a6f8b34
commit 288764b551
201 changed files with 1746 additions and 1144 deletions

View File

@ -10,7 +10,6 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("club", "0006_auto_20161229_0040"),

View File

@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("forum", "0001_initial")]
operations = [

View File

@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("forum", "0002_auto_20170312_1753")]
operations = [

View File

@ -6,7 +6,6 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [("forum", "0003_auto_20170510_1754")]
operations = [

View File

@ -6,7 +6,6 @@ from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("forum", "0004_auto_20170531_1949"),

View File

@ -6,7 +6,6 @@ import forum.models
class Migration(migrations.Migration):
dependencies = [("forum", "0005_forumtopic_subscribed_users")]
operations = [

View File

@ -157,10 +157,13 @@ class Forum(models.Model):
self.save()
_club_memberships = {} # This cache is particularly efficient:
# divided by 3 the number of requests on the main forum page
# after the first load
def is_owned_by(self, user):
if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID):
if user.is_anonymous:
return False
if user.is_in_group(pk=settings.SITH_GROUP_FORUM_ADMIN_ID):
return True
try:
m = Forum._club_memberships[self.id][user.id]
@ -336,7 +339,10 @@ class ForumMessage(models.Model):
def is_last_in_topic(self):
return bool(self.id == self.topic.messages.order_by("date").last().id)
def is_owned_by(self, user): # Anyone can create a topic: it's better to
def is_owned_by(self, user):
if user.is_anonymous:
return False
# Anyone can create a topic: it's better to
# check the rights at the forum level, since it's more controlled
return self.topic.forum.is_owned_by(user) or user.id == self.author.id

View File

@ -10,7 +10,11 @@
<div id="forum">
<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) or user.can_edit(forum) %}
{%
if user.is_com_admin
or user.is_in_group(pk=settings.SITH_GROUP_FORUM_ADMIN_ID)
or user.can_edit(forum)
%}
<a class="ib button" href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">{% trans %}New forum{% endtrans %}</a> <br/>
{% endif %}
{% if not forum.is_category %}

View File

@ -17,7 +17,10 @@
<a class="ib button" href="{{ url('forum:favorite_topics') }}">{% trans %}Favorite topics{% endtrans %}</a>
{{ display_search_bar(request) }}
</p>
{% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
{% if
user.is_com_admin
or user.is_in_group(pk=settings.SITH_GROUP_FORUM_ADMIN_ID)
%}
<p>
<a href="{{ url('forum:new_forum') }}">{% trans %}New forum{% endtrans %}</a>
</p>