Skip to content
Snippets Groups Projects
Verified Commit aa13d1b0 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

[Reformat] black

parent 0c53af5a
No related branches found
No related tags found
No related merge requests found
from django.contrib import admin
from .models import DashboardWidget, RSSFeedWidget, ICalFeedWidget
from .models import DashboardWidget, ICalFeedWidget, RSSFeedWidget
admin.site.register(DashboardWidget)
admin.site.register(RSSFeedWidget)
......
# Generated by Django 3.0.2 on 2020-01-29 16:57
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
......
# Generated by Django 3.0.3 on 2020-03-13 15:42
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
......
# Generated by Django 3.0.4 on 2020-03-18 12:12
from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
......
......@@ -15,12 +15,17 @@ class RSSFeedWidget(DashboardWidget):
template = "dashboardfeeds/rss.html"
url = models.URLField(verbose_name=_("RSS feed source URL"))
base_url = models.URLField(verbose_name=_("Base URL of related website"),
help_text=_("The widget will have a link to visit a related website to read more news"))
text_only = models.BooleanField(verbose_name=_("Text only"), help_text=_("Do not show an image to depict the news item"), default=False)
rss_source = models.ForeignKey(Source, on_delete=models.CASCADE, editable=False,
null=True)
base_url = models.URLField(
verbose_name=_("Base URL of related website"),
help_text=_("The widget will have a link to visit a related website to read more news"),
)
text_only = models.BooleanField(
verbose_name=_("Text only"),
help_text=_("Do not show an image to depict the news item"),
default=False,
)
rss_source = models.ForeignKey(Source, on_delete=models.CASCADE, editable=False, null=True)
def save(self, *args, **kwargs):
# Update the linked RSS source object to transfer data into django-feeds
......@@ -64,8 +69,10 @@ class ICalFeedWidget(DashboardWidget):
template = "dashboardfeeds/ical.html"
url = models.URLField(verbose_name=_("iCalendar URL"))
base_url = models.URLField(verbose_name=_("Base URL of related calendar"),
help_text=_("The widget will have a link to visit a related website to see more events"))
base_url = models.URLField(
verbose_name=_("Base URL of related calendar"),
help_text=_("The widget will have a link to visit a related website to see more events"),
)
events_count = models.IntegerField(verbose_name=_("Number of displayed events"), default=5)
def get_context(self):
......
INSTALLED_APPS = [
'feeds',
"feeds",
]
import logging
import re
from django.utils import timezone, formats
from django.core.cache import cache
from django.utils import formats, timezone
from ics import Calendar
from cache_memoize import cache_memoize
import requests
from cache_memoize import cache_memoize
from ics import Calendar
logger = logging.getLogger(__name__)
......@@ -54,12 +54,14 @@ def get_current_events(calendar: Calendar, limit: int = 5) -> list:
# Event has begin and end times
formatted = f"{begin_date_formatted} {begin_time_formatted}{end_date_formatted} {end_time_formatted}"
events.append({
"name": event.name,
"begin_timestamp": event.begin.timestamp,
"end_timestamp": event.end.timestamp,
"date_formatted": formatted,
})
events.append(
{
"name": event.name,
"begin_timestamp": event.begin.timestamp,
"end_timestamp": event.end.timestamp,
"date_formatted": formatted,
}
)
return events
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment