Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ shell-db:
sync-data: \
update-data \
enrich-data \
owasp-update-badges \
index-data

test-backend:
Expand All @@ -134,6 +135,7 @@ update-data: \
github-update-users \
owasp-aggregate-projects \
owasp-update-events \
owasp-sync-awards \
owasp-sync-posts \
owasp-update-sponsors \
slack-sync-data
52 changes: 5 additions & 47 deletions backend/apps/nest/admin/badge.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,15 @@
"""Admin configuration for the Badge model in the OWASP app."""
"""Badge admin configuration."""

from django.contrib import admin

from apps.nest.models.badge import Badge


@admin.register(Badge)
class BadgeAdmin(admin.ModelAdmin):
"""Admin for Badge model."""

fieldsets = (
(
"Basic Information",
{
"fields": (
"name",
"description",
"weight",
)
},
),
("Display Settings", {"fields": ("css_class",)}),
(
"Timestamps",
{
"fields": (
"nest_created_at",
"nest_updated_at",
)
},
),
)
list_display = (
"name",
"description",
"weight",
"css_class",
"nest_created_at",
"nest_updated_at",
)
list_display = ("name", "description", "weight", "css_class")
list_filter = ("weight",)
ordering = (
"weight",
"name",
)
readonly_fields = (
"nest_created_at",
"nest_updated_at",
)
search_fields = (
"css_class",
"description",
"name",
)


admin.site.register(Badge, BadgeAdmin)
search_fields = ("name", "description")
ordering = ("weight", "name")
12 changes: 12 additions & 0 deletions backend/apps/owasp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ owasp-process-snapshots:
@echo "Processing OWASP snapshots"
@CMD="python manage.py owasp_process_snapshots" $(MAKE) exec-backend-command

.PHONY: owasp-sync-awards

owasp-sync-awards:
@echo "Syncing OWASP awards data"
@CMD="python manage.py owasp_sync_awards" $(MAKE) exec-backend-command

owasp-update-leaders:
@CMD="python manage.py owasp_update_leaders $(MATCH_MODEL)" $(MAKE) exec-backend-command

Expand Down Expand Up @@ -63,3 +69,9 @@ owasp-update-events:
owasp-update-sponsors:
@echo "Getting OWASP sponsors data"
@CMD="python manage.py owasp_update_sponsors" $(MAKE) exec-backend-command

.PHONY: owasp-update-badges

owasp-update-badges:
@echo "Updating OWASP user badges"
@CMD="python manage.py owasp_update_badges" $(MAKE) exec-backend-command
1 change: 1 addition & 0 deletions backend/apps/owasp/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from apps.owasp.models.project_health_requirements import ProjectHealthRequirements

from .award import AwardAdmin
from .chapter import ChapterAdmin
from .committee import CommitteeAdmin
from .entity_member import EntityMemberAdmin
Expand Down
81 changes: 81 additions & 0 deletions backend/apps/owasp/admin/award.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Award admin configuration."""

from django.contrib import admin

from apps.owasp.models.award import Award


@admin.register(Award)
class AwardAdmin(admin.ModelAdmin):
"""Admin for Award model."""

list_display = (
"name",
"category",
"year",
"winner_name",
"user",
"is_reviewed",
"nest_created_at",
"nest_updated_at",
)
list_display_links = ("name", "winner_name")
list_per_page = 50
list_filter = (
"category",
"year",
"is_reviewed",
)
search_fields = (
"name",
"winner_name",
"description",
"winner_info",
"user__login",
)
ordering = ("-year", "category", "name")

autocomplete_fields = ("user",)
actions = ("mark_reviewed", "mark_not_reviewed")
list_select_related = ("user",)

fieldsets = (
(
"Basic Information",
{"fields": ("name", "category", "year", "description")},
),
(
"Winner Information",
{
"fields": (
"winner_name",
"winner_info",
"winner_image_url",
"user",
"is_reviewed",
),
"classes": ("collapse",),
},
),
(
"Timestamps",
{
"fields": ("nest_created_at", "nest_updated_at"),
"classes": ("collapse",),
},
),
)

readonly_fields = ("nest_created_at", "nest_updated_at")

@admin.action(description="Mark selected awards as reviewed")
def mark_reviewed(self, request, queryset):
"""Mark selected awards as reviewed."""
updated = queryset.update(is_reviewed=True)
self.message_user(request, f"Marked {updated} award(s) as reviewed.")

@admin.action(description="Mark selected awards as not reviewed")
def mark_not_reviewed(self, request, queryset):
"""Mark selected awards as not reviewed."""
updated = queryset.update(is_reviewed=False)
self.message_user(request, f"Marked {updated} award(s) as not reviewed.")
Loading