-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
897cdbd
commit 977c123
Showing
14 changed files
with
499 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from django.contrib import admin, messages | ||
from django.shortcuts import get_object_or_404, redirect | ||
from django.urls import path | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from core.models.organizerissue import OrganizerIssue | ||
|
||
from .forms.organizerissue import OrganizerIssueForm | ||
|
||
|
||
class OrganizerIssueAdmin(admin.ModelAdmin): | ||
form = OrganizerIssueForm | ||
list_display = ( | ||
"organizer", | ||
"event", | ||
"date_reported", | ||
"reported_by", | ||
"issue_handled", | ||
"issue_handled_by", | ||
"last_updated", | ||
) | ||
list_filter = ( | ||
"organizer", | ||
"event", | ||
"reported_by", | ||
) | ||
search_fields = ( | ||
"organizer", | ||
"event", | ||
"reported_by", | ||
) | ||
|
||
def get_urls(self): | ||
urls = super().get_urls() | ||
|
||
my_urls = [ | ||
path( | ||
"<int:organizerissue_id>/triage/blacklist/", | ||
self.admin_site.admin_view(self.blacklist), | ||
name="core_organizerissue_blacklist", | ||
), | ||
path( | ||
"<int:organizerissue_id>/triage/reverse_blacklist/", | ||
self.admin_site.admin_view(self.reverse_blacklist), | ||
name="core_organizerissue_reverse_blacklist", | ||
), | ||
] | ||
return my_urls + urls | ||
|
||
def blacklist(self, request, organizerissue_id): | ||
organizer = get_object_or_404(OrganizerIssue, id=organizerissue_id) | ||
organizer.blacklist_organizer() | ||
messages.success( | ||
request, | ||
_("Organizer %(organizer)s, of %(event)s has been blacklisted.") | ||
% {"organizer": f"{organizer.organizer.get_full_name()}", "event": organizer.event}, | ||
) | ||
return redirect("admin:core_organizerissue_changelist") | ||
|
||
def reverse_blacklist(self, request, organizerissue_id): | ||
organizer = get_object_or_404(OrganizerIssue, id=organizerissue_id) | ||
organizer.reverse_blacklist_organizer() | ||
messages.success( | ||
request, | ||
_("Blacklisting for organizer %(organizer)s, of %(event)s has been reversed.") | ||
% {"organizer": f"{organizer.organizer.get_full_name()}", "event": organizer.event}, | ||
) | ||
return redirect("admin:core_organizerissue_changelist") | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Generated by Django 3.2.20 on 2024-01-30 16:44 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.db.models.manager | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0005_auto_20220422_1321"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelManagers( | ||
name="event", | ||
managers=[ | ||
("all_objects", django.db.models.manager.Manager()), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name="user", | ||
name="is_blacklisted", | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.CreateModel( | ||
name="OrganizerIssue", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("date_reported", models.DateField()), | ||
("reported_by", models.CharField(max_length=100)), | ||
("reporter_email", models.EmailField(max_length=100)), | ||
("issue", models.TextField()), | ||
("issue_handled", models.BooleanField()), | ||
("findings", models.TextField(blank=True, null=True)), | ||
("comments", models.TextField(blank=True, null=True)), | ||
("last_updated", models.DateTimeField(auto_now=True)), | ||
( | ||
"event", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="event", | ||
to="core.event", | ||
), | ||
), | ||
( | ||
"issue_handled_by", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="staff_responsible", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"organizer", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="oganizer", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +0,0 @@ | ||
from django.db import models | ||
from models.event import Event | ||
from models.user import User | ||
|
||
|
||
class OrganizerIssue(models.Model): | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
organizer = models.ForeignKey(User, related_name="oganizer", on_delete=models.deletion.CASCADE) | ||
event = models.ForeignKey(to=Event, null=True, blank=True, related_name="event", on_delete=models.deletion.SET_NULL) | ||
date_reported = models.DateField() | ||
reported_by = models.CharField(max_length=100) | ||
reporter_email = models.EmailField(max_length=100) | ||
issue = models.TextField() | ||
issue_handled = models.BooleanField() | ||
issue_handled_by = models.ForeignKey( | ||
to=User, null=True, blank=True, related_name="staff_responsible", on_delete=models.deletion.SET_NULL | ||
) | ||
findings = models.TextChoices(blank=True, null=True) | ||
comments = models.TextField(blank=True, null=True) | ||
last_updated = models.DateTimeField(auto_now=True) | ||
|
||
def __str__(self): | ||
return f"{self.organizer.get_full_name()} - {self.event}" | ||
|
||
def blacklist_organizer(self): | ||
user = User.objects.get(id=self.organizer) | ||
user.is_blacklisted = True | ||
user.save() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.db import models | ||
|
||
|
||
class OrganizerManager(models.Manager): | ||
pass | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.