Skip to content

Commit 3fa7da4

Browse files
committed
Address PR review comments
- Move imports to top of file instead of inside function - Update _STATUS_LABELS in models to use Bootstrap 5 class names directly - Remove mapping logic from template tags - Remove unnecessary comments from JavaScript - Use relevant_commitfests() in context processor for efficiency - Revert close button to simple Bootstrap 5 btn-close styling - Reuse existing cfs variable in home view instead of querying again
1 parent 0855cfc commit 3fa7da4

File tree

7 files changed

+17
-44
lines changed

7 files changed

+17
-44
lines changed

media/commitfest/css/commitfest.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,9 @@ a:hover .badge {
146146
.navbar-dark .github-logo {
147147
filter: brightness(0) invert(1);
148148
}
149+
150+
/* Simple close button without float */
151+
.btn-close-nofloat {
152+
float: none;
153+
margin-left: 0.5rem;
154+
}

media/commitfest/js/commitfest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,7 @@ function sortpatches(sortby) {
280280
function toggleButtonCollapse(buttonId, collapseId) {
281281
const button = document.getElementById(buttonId);
282282
const collapse = document.getElementById(collapseId);
283-
284-
// Toggle button active state
285283
button.classList.toggle("active");
286-
287-
// Use Bootstrap 5 Collapse API
288284
const bsCollapse = new bootstrap.Collapse(collapse, {
289285
toggle: true,
290286
});

pgcommitfest/commitfest/context_processors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
def global_context(request):
55
"""Add global context variables available in all templates."""
6+
cfs = CommitFest.relevant_commitfests()
67
return {
7-
"current_cf": CommitFest.get_current(),
8-
"open_cf": CommitFest.get_open_regular(),
8+
"current_cf": cfs.get("in_progress") or cfs.get("open"),
9+
"open_cf": cfs.get("open"),
910
}

pgcommitfest/commitfest/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class PatchOnCommitFest(models.Model):
535535
(STATUS_WITHDRAWN, "Withdrawn"),
536536
)
537537
_STATUS_LABELS = (
538-
(STATUS_REVIEW, "default"),
538+
(STATUS_REVIEW, "secondary"),
539539
(STATUS_AUTHOR, "primary"),
540540
(STATUS_COMMITTER, "info"),
541541
(STATUS_COMMITTED, "success"),

pgcommitfest/commitfest/templates/patch.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
{%endif%}
136136
<dl>
137137
{%for t in patch.mailthread_set.all%}
138-
<dt><a href="https://www.postgresql.org/message-id/flat/{{t.messageid}}">{{t.subject}}</a> <button type="button" class="btn btn-outline-danger btn-sm ms-2" title="Detach this thread" onclick="detachThread({{cf.id}},{{patch.id}},'{{t.messageid}}')">×</button></dt>
138+
<dt><a href="https://www.postgresql.org/message-id/flat/{{t.messageid}}">{{t.subject}}</a> <button type="button" class="btn-close btn-close-nofloat" title="Detach this thread" onclick="detachThread({{cf.id}},{{patch.id}},'{{t.messageid}}')"></button></dt>
139139
<dd>
140140
First at <a href="https://www.postgresql.org/message-id/{{t.messageid}}">{{t.firstmessage}}</a> by {{t.firstauthor|hidemail}}<br/>
141141
Latest at <a href="https://www.postgresql.org/message-id/{{t.latestmsgid}}">{{t.latestmessage}}</a> by {{t.latestauthor|hidemail}}<br/>

pgcommitfest/commitfest/templatetags/commitfest.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,7 @@ def commitfeststatusstring(value):
2525
@stringfilter
2626
def commitfeststatuslabel(value):
2727
i = int(value)
28-
bootstrap3_class = [v for k, v in CommitFest._STATUS_LABELS if k == i][0]
29-
# Map Bootstrap 3 label classes to Bootstrap 5 badge classes
30-
mapping = {
31-
"default": "secondary",
32-
"primary": "primary",
33-
"info": "info",
34-
"success": "success",
35-
"warning": "warning",
36-
"danger": "danger",
37-
}
38-
return mapping.get(bootstrap3_class, "secondary")
28+
return [v for k, v in CommitFest._STATUS_LABELS if k == i][0]
3929

4030

4131
@register.filter(name="patchstatusstring")
@@ -49,17 +39,7 @@ def patchstatusstring(value):
4939
@stringfilter
5040
def patchstatuslabel(value):
5141
i = int(value)
52-
bootstrap3_class = [v for k, v in PatchOnCommitFest._STATUS_LABELS if k == i][0]
53-
# Map Bootstrap 3 label classes to Bootstrap 5 badge classes
54-
mapping = {
55-
"default": "secondary",
56-
"primary": "primary",
57-
"info": "info",
58-
"success": "success",
59-
"warning": "warning", # Keep warning but we'll override the color in CSS
60-
"danger": "danger",
61-
}
62-
return mapping.get(bootstrap3_class, "secondary")
42+
return [v for k, v in PatchOnCommitFest._STATUS_LABELS if k == i][0]
6343

6444

6545
@register.filter(name="tagname")

pgcommitfest/commitfest/views.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
HttpResponseRedirect,
1212
)
1313
from django.shortcuts import get_object_or_404, render
14+
from django.utils import timezone
1415
from django.views.decorators.csrf import csrf_exempt
1516

1617
import collections
1718
import hmac
1819
import json
1920
import urllib
20-
from datetime import datetime
21+
from datetime import datetime, timedelta
2122
from email.mime.text import MIMEText
2223
from email.utils import formatdate, make_msgid
2324

@@ -60,10 +61,6 @@ def home(request):
6061
# Add dashboard content for logged-in users (same as me() view)
6162
if request.user.is_authenticated:
6263
# Check if user is experienced (has been active for a while)
63-
from django.db import connection
64-
from django.utils import timezone
65-
66-
from datetime import timedelta
6764

6865
# Consider user experienced if they joined more than 30 days ago
6966
is_experienced_user = request.user.date_joined < timezone.now() - timedelta(
@@ -74,16 +71,9 @@ def home(request):
7471

7572
curs = connection.cursor()
7673
curs.execute("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")
77-
current_cfs = list(
78-
CommitFest.objects.filter(status=CommitFest.STATUS_INPROGRESS)
79-
)
80-
if len(current_cfs) == 0:
81-
current_cfs = list(CommitFest.objects.filter(status=CommitFest.STATUS_OPEN))
8274

83-
if len(current_cfs) > 0:
84-
cf = current_cfs[0]
85-
else:
86-
cf = None
75+
# Use existing cfs data instead of querying again
76+
cf = cfs.get("in_progress") or cfs.get("open")
8777

8878
form = CommitFestFilterForm(request.GET)
8979
patch_list = patchlist(request, cf, personalized=True)

0 commit comments

Comments
 (0)