Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add tags to patches #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c0b0dc7
Add Tags for patches
jchampio May 30, 2025
02aa97f
Help admins choose tag colors with contrast
jchampio May 31, 2025
180ac89
Add selectize support to tag picker
JelteF Jun 9, 2025
415c41a
Allow filtering by tags
JelteF Jun 9, 2025
b86c4d1
Run make fix
JelteF Jun 9, 2025
1d605a0
Allow clicking on a tag in commitfest overview page
JelteF Jun 9, 2025
c982722
Merge branch 'main' into dev/tags-2
JelteF Jun 15, 2025
c105746
Fix merge
JelteF Jun 15, 2025
d1bf0fd
Add default tags, descriptions, and raw hex code input
JelteF Jun 15, 2025
7ae88ae
Add tags to patches in dummy data and fix tag display in history
JelteF Jun 15, 2025
dfc14ea
Add description as hovertext for tags
JelteF Jun 15, 2025
7122202
Add description as hovertext for tags on patch page
JelteF Jun 15, 2025
f6d2396
Add tags to dashboard
JelteF Jun 15, 2025
e8ee2bb
Use spaces + title case in default tags
JelteF Jun 16, 2025
e7fba3e
Allow filtering by multiple tags at once
JelteF Jun 16, 2025
a88dc7a
More default tags
JelteF Jun 16, 2025
467d483
Update dummy data dump with new tags
JelteF Jun 16, 2025
92e98e5
Formatting
JelteF Jun 16, 2025
9cc55f6
Add validation also to text field
JelteF Jun 16, 2025
e20ca39
Auto formatting
JelteF Jun 16, 2025
551d958
Merge remote-tracking branch 'origin' into dev/tags-2
JelteF Jun 16, 2025
b8ae995
Update change messages with new tag names
JelteF Jun 16, 2025
31a4afc
Add comment about SQL injection consideration
JelteF Jun 16, 2025
8c714bd
Use repeatable read for commitfest and dashboard query
JelteF Jun 16, 2025
fd2c93e
Merge branch 'main' into dev/tags-2
JelteF Jun 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ignore": [],
"include": [
"media/commitfest/js/commitfest.js",
"media/commitfest/js/change_tag.js",
"media/commitfest/css/commitfest.css",
"biome.json"
]
Expand Down
45 changes: 45 additions & 0 deletions media/commitfest/js/change_tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// An input validator for the color picker. Points out low-contrast tag color
// choices.
const inputs = document.getElementsByClassName("color-picker");
for (let i = 0; i < inputs.length; i++) {
inputs[i].addEventListener("change", (event) => {
// Don't do anything if the color code doesn't pass default validity.
const element = event.target;
element.setCustomValidity("");
if (!element.validity.valid) {
return;
}

// Break the #rrggbb color code into RGB components.
color = Number.parseInt(element.value.substr(1), 16);
red = ((color & 0xff0000) >> 16) / 255;
green = ((color & 0x00ff00) >> 8) / 255;
blue = (color & 0x0000ff) / 255;

// Compare the contrast ratio against white. All the magic math comes from
// Web Content Accessibility Guidelines (WCAG) 2.2, Technique G18:
//
// https://www.w3.org/WAI/WCAG22/Techniques/general/G18.html
//
function l(val) {
if (val <= 0.04045) {
return val / 12.92;
}
return ((val + 0.055) / 1.055) ** 2.4;
}

lum = 0.2126 * l(red) + 0.7152 * l(green) + 0.0722 * l(blue);
contrast = (1 + 0.05) / (lum + 0.05);

// Complain if we're below WCAG 2.2 recommendations.
if (contrast < 4.5) {
element.setCustomValidity(
`Consider choosing a darker color. (Tag text is small and white.)\n\nContrast ratio: ${Math.trunc(contrast * 10) / 10} (< 4.5)`,
);

// The admin form uses novalidate, so manually display the browser's
// validity popup. (The user can still ignore it if desired.)
element.reportValidity();
}
});
}
21 changes: 21 additions & 0 deletions pgcommitfest/commitfest/admin.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from django.contrib import admin
from django.forms import widgets

from .models import (
CfbotBranch,
CfbotTask,
ColorField,
CommitFest,
Committer,
MailThread,
MailThreadAttachment,
Patch,
PatchHistory,
PatchOnCommitFest,
Tag,
TargetVersion,
Topic,
)
Expand Down Expand Up @@ -38,8 +41,26 @@ class MailThreadAttachmentAdmin(admin.ModelAdmin):
)


class ColorInput(widgets.Input):
"""
A color picker widget.
"""

input_type = "color"
template_name = "color_input.html"


class TagAdmin(admin.ModelAdmin):
# Customize the Tag form with a color picker and soft validation.
change_form_template = "change_tag_form.html"
formfield_overrides = {
ColorField: {"widget": ColorInput},
}


admin.site.register(Committer, CommitterAdmin)
admin.site.register(CommitFest)
admin.site.register(Tag, TagAdmin)
admin.site.register(Topic)
admin.site.register(Patch, PatchAdmin)
admin.site.register(PatchHistory)
Expand Down
Loading