Add more details to the iCal sync admin overview page

This commit is contained in:
Kevin Alberts 2020-11-11 20:19:45 +01:00
parent 16177f853d
commit 079847ae4e
Signed by: Kurocon
GPG key ID: BCD496FEBA0C6BC1
2 changed files with 5 additions and 0 deletions

View file

@ -5,5 +5,6 @@ from davinci.icalendar.models import ICalSync
class ICalSyncAdmin(admin.ModelAdmin):
form = ICalSyncForm
list_display = ['name', 'target', 'purge', 'humanized_sync_interval', 'last_sync', 'active']
admin.site.register(ICalSync, ICalSyncAdmin)

View file

@ -24,6 +24,10 @@ class ICalSync(models.Model):
def __str__(self):
return f'{self.name} to {self.target} every {humanize.precisedelta(self.sync_interval)}'
@property
def humanized_sync_interval(self):
return humanize.precisedelta(self.sync_interval)
def get_events(self):
data = ical_utils.get_ical_from_url(self.ical_url)
return ical_utils.split_events(data)