Skip to content

Commit

Permalink
Added admin options
Browse files Browse the repository at this point in the history
  • Loading branch information
danielengelhardt committed Aug 1, 2023
1 parent 3833497 commit d880c36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion DSTBundesliga/apps/dstffbl/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import pytz
from django.contrib import admin
from django.http import HttpResponse
from django.urls import reverse
from django.utils.html import format_html

from DSTBundesliga.apps.dstffbl.models import News, Announcement, SeasonUser, SeasonInvitation, SeasonRegistration, \
DSTEmail
Expand Down Expand Up @@ -67,10 +69,13 @@ def get_sleeper_username(self, obj):
get_sleeper_username.short_description = 'Sleeper Username'

list_display = ['email', 'get_sleeper_username', 'sleeper_id', 'region', 'new_player', 'last_years_league',
'possible_commish', 'registration_ts']
'possible_commish', 'registration_ts', "confirm_registration"]
search_fields = ['user__email', 'dst_player__display_name', 'sleeper_id', 'last_years_league__sleeper_name']
list_filter = ('season', 'region', 'new_player', 'possible_commish')

def confirm_registration(self, obj):
return format_html("<a href='{url}'>Registrierung bestätigen</a>", url=obj.url)


class SeasonInvitationAdmin(admin.ModelAdmin):
def get_sleeper_username(self, obj):
Expand All @@ -83,6 +88,7 @@ def get_sleeper_username(self, obj):
class DSTEmailAdmin(admin.ModelAdmin):
list_display = ['type', 'recipient', 'subject', 'send_ts', 'has_erros']
list_filter = ('type', 'has_erros')
search_fields = ["recipient"]
ordering = ['-send_ts']


Expand Down
4 changes: 4 additions & 0 deletions DSTBundesliga/apps/dstffbl/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def get_email_to(self):
def get_email_type(self):
return 1

@property
def url(self):
return reverse("dstffbl:accept_invite", kwargs={"registration_id": self.id})


class SeasonUser(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
Expand Down

0 comments on commit d880c36

Please sign in to comment.