-
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
6a05d70
commit 897cdbd
Showing
6 changed files
with
134 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from django import forms | ||
from models.event import Event | ||
from models.organizer import OrganizerIssue | ||
from models.user import User | ||
|
||
|
||
class OrganizerIssueForm(forms.ModelForm): | ||
organizer = forms.ModelChoiceField(queryset=User.objects.all()) | ||
event = forms.ModelChoiceField(queryset=Event.objects.all()) | ||
issue_handled_by = forms.ModelChoiceField(queryset=User.objects.filter(is_staff=True)) | ||
|
||
class Meta: | ||
model = OrganizerIssue | ||
fields = ( | ||
"organizer", | ||
"event", | ||
"date_reported", | ||
"reported_by", | ||
"issue", | ||
"issue_handled", | ||
"issue_handled_by", | ||
"findings", | ||
"comments", | ||
"last_updated", | ||
) |
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,50 @@ | ||
from django.contrib import admin, messages | ||
from django.shortcuts import get_object_or_404 | ||
from django.urls import path | ||
from django.utils.translation import gettext_lazy as _ | ||
from models.organizer import OrganizerIssue | ||
|
||
|
||
@admin.register(OrganizerIssue) | ||
class OrganizerIssueAdmin(admin.ModelAdmin): | ||
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>/blacklist_organizer/", | ||
self.admin_site.admin_view(self.blacklist_organizer), | ||
name="core_organizer_blacklist_organizer", | ||
), | ||
] | ||
|
||
return my_urls + urls | ||
|
||
def blacklist_organizer(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 blackliste.") | ||
% {"organizer": f"{organizer.organizer.get_full_name()}", "event": organizer.event}, | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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,29 @@ | ||
from django.db import models | ||
|
||
from .event import Event | ||
from .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