public-health-ch/feedler/models/admin.py

30 lines
960 B
Python
Raw Normal View History

2017-07-03 11:36:01 +00:00
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.db import models
from django.db.models.signals import pre_save
from django.dispatch import receiver
from django.core.mail import send_mail
from wagtail.contrib.settings.models import BaseSetting, register_setting
2017-07-03 14:01:44 +00:00
2017-10-13 13:40:24 +00:00
from .models import Stream
2017-07-03 14:01:44 +00:00
2017-10-13 13:40:24 +00:00
from feedler.refresh import refresh_streams
2017-07-03 11:36:01 +00:00
@register_setting
class FeedlySettings(BaseSetting):
2017-10-13 13:40:24 +00:00
streams = models.ManyToManyField(Stream,
2017-09-20 10:18:12 +00:00
help_text='Which streams to update')
2017-10-13 21:45:55 +00:00
token = models.CharField(max_length=1024, blank=True,
help_text='Access Token from feedly.com/v3/auth/dev')
refresh = models.CharField(max_length=1024, blank=True,
help_text='Refresh Token for automatic update (pro account)')
2017-07-03 11:36:01 +00:00
class Meta:
verbose_name = 'Feedly'
2017-10-14 21:58:50 +00:00
# @receiver(pre_save, sender=FeedlySettings)
# def handle_save_settings(sender, instance, *args, **kwargs):
# if instance.token: refresh_streams(instance)