Skip to content

Commit

Permalink
Merge branch 'dev' into feature/quick_domain_ban
Browse files Browse the repository at this point in the history
  • Loading branch information
philippemilink committed Oct 13, 2024
2 parents 798bf80 + 9efd817 commit 1fcacdb
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 26 deletions.
9 changes: 0 additions & 9 deletions fixtures/topics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
forum: 10
author: 3
pubdate: 2013-12-21 13:20:30
update_index_date: 2013-12-21 13:20:30
last_message: 1
- model: forum.Topic
pk: 2
Expand All @@ -16,7 +15,6 @@
forum: 3
author: 3
pubdate: 2013-12-21 13:20:30
update_index_date: 2013-12-21 13:20:30
last_message: 2
- model: forum.Topic
pk: 3
Expand All @@ -25,7 +23,6 @@
forum: 2
author: 3
pubdate: 2013-12-21 13:20:30
update_index_date: 2013-12-21 13:20:30
last_message: 4
- model: forum.Topic
pk: 4
Expand All @@ -34,7 +31,6 @@
forum: 12
author: 3
pubdate: 2014-01-05 18:20:30
update_index_date: 2013-12-21 13:20:30
last_message: 5
- model: forum.Post
pk: 1
Expand All @@ -49,7 +45,6 @@
like: 42
dislike: 0
pubdate: 2013-12-21 13:20:30
update_index_date: 2013-12-21 13:20:30
position: 1
- model: forum.Post
pk: 2
Expand All @@ -64,7 +59,6 @@
like: 3
dislike: 12
pubdate: 2013-12-21 13:20:30
update_index_date: 2013-12-21 13:20:30
position: 1
- model: forum.Post
pk: 3
Expand All @@ -79,7 +73,6 @@
like: 42
dislike: 0
pubdate: 2013-12-21 13:22:30
update_index_date: 2013-12-21 13:20:30
position: 2
- model: forum.Post
pk: 4
Expand All @@ -94,7 +87,6 @@
like: 0
dislike: 0
pubdate: 2013-12-21 13:20:30
update_index_date: 2013-12-21 13:20:30
position: 1
- model: forum.Post
pk: 5
Expand Down Expand Up @@ -275,5 +267,4 @@
like: 1337
dislike: 0
pubdate: 2014-01-05 18:20:30
update_index_date: 2013-12-21 13:20:30
position: 1
1 change: 1 addition & 0 deletions templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ <h1 class="dropdown-title">{% trans "Alertes de modération" %}</h1>
{% endif %}
>
{% avatar profile %}
<span class="visuallyhidden">Mon profil</span>
<span class="username label">{{ user.username }}</span>
</a>
{% endwith %}
Expand Down
6 changes: 2 additions & 4 deletions templates/misc/avatar.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

{# Template used by the templatetag "avatar" defined in zds/utils/templatetags/profile.py #}

{% captureas alt_text %}Avatar de {{ username }}{% endcaptureas %}

{% if avatar_url %}
<img src="{{ avatar_url }}" alt="{{ alt_text }}" class="avatar" itemprop="image" aria-hidden="true">
<img src="{{ avatar_url }}" alt="" class="avatar" itemprop="image" aria-hidden="true">
{% else %}
<canvas width="{{ avatar_size }}" height="{{ avatar_size }}" data-jdenticon-value="{{ username }}" class="avatar">{{ alt_text }}</canvas>
<canvas width="{{ avatar_size }}" height="{{ avatar_size }}" data-jdenticon-value="{{ username }}" class="avatar" aria-hidden="true"></canvas>
{% endif %}
4 changes: 0 additions & 4 deletions zds/forum/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ def perform_edit_post(request, post, user, text):
post.editor = user
post.save()

# Save topic to update update_index_date
if post.position == 1:
post.topic.save()

return post


Expand Down
17 changes: 17 additions & 0 deletions zds/forum/migrations/0025_remove_update_index_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.16 on 2024-10-02 23:09

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("forum", "0024_rename_search_fields"),
]

operations = [
migrations.RemoveField(
model_name="topic",
name="update_index_date",
),
]
3 changes: 0 additions & 3 deletions zds/forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ class Meta:
"Post", null=True, related_name="last_message", verbose_name="Dernier message", on_delete=models.SET_NULL
)
pubdate = models.DateTimeField("Date de création", auto_now_add=True)
update_index_date = models.DateTimeField(
"Date de dernière modification pour la réindexation partielle", auto_now=True, db_index=True
)
solved_by = models.ForeignKey(
User,
verbose_name="Utilisateur ayant noté le sujet comme résolu",
Expand Down
6 changes: 6 additions & 0 deletions zds/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,8 @@ def test_creation_archive_on_edit(self):
topic = create_topic_in_forum(forum, profile)
post_before_edit = Post.objects.get(pk=topic.last_message.pk)

post_before_edit.save(search_engine_requires_index=False)

edits_count = CommentEdit.objects.count()

# Edit post
Expand All @@ -1537,6 +1539,10 @@ def test_creation_archive_on_edit(self):
self.assertEqual(post_before_edit.text, edit.original_text)
self.assertEqual(profile.user, edit.editor)

# Check the post was marked as to reindex
post_before_edit.refresh_from_db()
self.assertTrue(post_before_edit.search_engine_requires_index)


class PostUsefulTest(TestCase):
def test_failure_post_useful_require_method_post(self):
Expand Down
7 changes: 4 additions & 3 deletions zds/utils/management/commands/load_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,11 @@ def load_contents(cli, size, fake, _type, *_, **__):

current_size = content_sizes[created_content_index]
action_flag = what_to_do[created_content_index]
title = ["Mini", "Medium", "Big"][current_size] + " " + fake.text(max_nb_chars=50)

# creation:
content = PublishableContentFactory(
type=_type, title=fake.text(max_nb_chars=60), description=fake.sentence(nb_words=15, variable_nb_words=True)
type=_type, title=title, description=fake.sentence(nb_words=15, variable_nb_words=True)
)

versioned = content.load_version()
Expand Down Expand Up @@ -564,12 +565,12 @@ def validate_edited_content(content, fake, nb_staffs, staffs, to_do, versioned):


def generate_text_for_content(content_size, fake, nb_avg_containers_in_content, nb_avg_extracts_in_content, versioned):
if content_size == 0:
if content_size == 0: # mini
nb_extracts = random.randint(1, nb_avg_extracts_in_content * 2)
for _ in range(nb_extracts):
extract_title = fake.text(max_nb_chars=60)
ExtractFactory(container=versioned, title=extract_title, light=False)
else:
else: # medium or big
nb_containers = random.randint(1, nb_avg_containers_in_content * 2)
for _ in range(nb_containers):
container_title = fake.text(max_nb_chars=60)
Expand Down
17 changes: 17 additions & 0 deletions zds/utils/migrations/0027_remove_update_index_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.16 on 2024-10-02 23:09

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("utils", "0026_customsession"),
]

operations = [
migrations.RemoveField(
model_name="comment",
name="update_index_date",
),
]
3 changes: 0 additions & 3 deletions zds/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ class Meta:

pubdate = models.DateTimeField("Date de publication", auto_now_add=True, db_index=True)
update = models.DateTimeField("Date d'édition", null=True, blank=True)
update_index_date = models.DateTimeField(
"Date de dernière modification pour la réindexation partielle", auto_now=True, db_index=True
)

is_visible = models.BooleanField("Est visible", default=True)
text_hidden = models.CharField("Texte de masquage ", max_length=80, default="")
Expand Down

0 comments on commit 1fcacdb

Please sign in to comment.