Skip to content

Commit e4907d3

Browse files
committed
ref(notifications): improve naming
1 parent 8d19025 commit e4907d3

File tree

5 files changed

+67
-11
lines changed

5 files changed

+67
-11
lines changed

legadilo/feeds/models/feed.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def log_error(self, feed: Feed, error_message: str, technical_debug_data: dict |
329329
user=feed.user,
330330
title=_("Feed '%s' was disabled") % feed.title,
331331
content=str(message),
332-
url=reverse("feeds:edit_feed", kwargs={"feed_id": feed.id}),
333-
url_text=str(_("Edit feed")),
332+
info_link=reverse("feeds:edit_feed", kwargs={"feed_id": feed.id}),
333+
info_link_text=str(_("Edit feed")),
334334
)
335335

336336
def log_not_modified(self, feed: Feed):

legadilo/feeds/tests/test_models/test_feed.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ def test_disabled(self):
496496
assert not notification.is_read
497497
assert notification.title == f"Feed '{self.feed.title}' was disabled"
498498
assert notification.content == "We failed too many times to fetch the feed"
499-
assert re.match(r"/feeds/\d+/", notification.url)
500-
assert notification.url_text == "Edit feed"
499+
assert re.match(r"/feeds/\d+/", notification.info_link)
500+
assert notification.info_link_text == "Edit feed"
501501

502502
def test_update_feed(self, django_assert_num_queries):
503503
existing_article = ArticleFactory(

legadilo/templates/users/notifications.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ <h2 class="card-title">{{ notification.title }}</h2>
2020
</header>
2121
<main class="card-text">
2222
<p class="mb-1">{{ notification.content }}</p>
23-
{% if notification.url %}
24-
<a class="card-link" href="{{ notification.url }}">{{ notification.url_text }}</a>
23+
{% if notification.info_link %}
24+
<a class="card-link" href="{{ notification.info_link }}">{{ notification.info_link_text }}</a>
2525
{% endif %}
2626
</main>
2727
<form class="mt-2" method="post" hx-boost="true" hx-push-url="false">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Legadilo
2+
# Copyright (C) 2023-2025 by Legadilo contributors.
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Affero General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Affero General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Affero General Public License
15+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
# Generated by Django 5.2 on 2025-04-12 10:27
18+
19+
from django.db import migrations, models
20+
21+
22+
class Migration(migrations.Migration):
23+
dependencies = [
24+
(
25+
"users",
26+
"0008_remove_notification_users_notification_link_and_text_set_together_and_more",
27+
),
28+
]
29+
30+
operations = [
31+
migrations.RemoveConstraint(
32+
model_name="notification",
33+
name="users_notification_url_and_text_set_together",
34+
),
35+
migrations.RenameField(
36+
model_name="notification",
37+
old_name="url",
38+
new_name="info_link",
39+
),
40+
migrations.RenameField(
41+
model_name="notification",
42+
old_name="url_text",
43+
new_name="info_link_text",
44+
),
45+
migrations.AddConstraint(
46+
model_name="notification",
47+
constraint=models.CheckConstraint(
48+
condition=models.Q(
49+
models.Q(("info_link__length", 0), ("info_link_text__length", 0)),
50+
models.Q(("info_link__length__gt", 0), ("info_link_text__length__gt", 0)),
51+
_connector="OR",
52+
),
53+
name="users_notification_info_link_and_info_link_text_set_together",
54+
),
55+
),
56+
]

legadilo/users/models/notification.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def mark_as_unread(self, user: User, notification_id: int | None = None) -> None
8383
class Notification(models.Model):
8484
title = models.CharField(max_length=100)
8585
content = models.TextField(blank=True)
86-
url = models.URLField(blank=True)
87-
url_text = models.CharField(max_length=100, blank=True)
86+
info_link = models.URLField(blank=True)
87+
info_link_text = models.CharField(max_length=100, blank=True)
8888
read_at = models.DateTimeField(null=True, blank=True)
8989
is_read = models.GeneratedField(
9090
expression=models.Case(
@@ -104,9 +104,9 @@ class Notification(models.Model):
104104
class Meta(TypedModelMeta):
105105
constraints = [
106106
models.CheckConstraint(
107-
name="%(app_label)s_%(class)s_url_and_text_set_together",
108-
condition=(models.Q(url__length=0) & models.Q(url_text__length=0))
109-
| (models.Q(url__length__gt=0) & models.Q(url_text__length__gt=0)),
107+
name="%(app_label)s_%(class)s_info_link_and_info_link_text_set_together",
108+
condition=(models.Q(info_link__length=0) & models.Q(info_link_text__length=0))
109+
| (models.Q(info_link__length__gt=0) & models.Q(info_link_text__length__gt=0)),
110110
),
111111
]
112112

0 commit comments

Comments
 (0)