Compare commits
3 Commits
bcc5f767ba
...
ab0d738851
Author | SHA1 | Date | |
---|---|---|---|
ab0d738851 | |||
9d94155f66 | |||
a6f8fc5dc1 |
23
countdown/migrations/0006_auto_20201025_1716.py
Normal file
23
countdown/migrations/0006_auto_20201025_1716.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.2 on 2020-10-25 17:16
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('countdown', '0005_countdownitem_recurring_until'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='countdownitem',
|
||||||
|
name='recurring_period',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=64),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='countdownitem',
|
||||||
|
name='reminder_target',
|
||||||
|
field=models.CharField(blank=True, default='', max_length=64),
|
||||||
|
),
|
||||||
|
]
|
@ -1,14 +1,8 @@
|
|||||||
"""Countdown item models."""
|
"""Countdown item models."""
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('countdown.models')
|
|
||||||
|
|
||||||
|
|
||||||
class CountdownItem(models.Model):
|
class CountdownItem(models.Model):
|
||||||
"""Track points in time."""
|
"""Track points in time."""
|
||||||
|
|
||||||
@ -19,13 +13,13 @@ class CountdownItem(models.Model):
|
|||||||
sent_reminder = models.BooleanField(default=False)
|
sent_reminder = models.BooleanField(default=False)
|
||||||
|
|
||||||
reminder_message = models.TextField(default="")
|
reminder_message = models.TextField(default="")
|
||||||
reminder_target = models.CharField(max_length=64, default='')
|
reminder_target = models.CharField(max_length=64, blank=True, default='')
|
||||||
|
|
||||||
recurring_period = models.CharField(max_length=64, default='')
|
recurring_period = models.CharField(max_length=64, blank=True, default='')
|
||||||
recurring_until = models.DateTimeField(null=True, blank=True, default=None)
|
recurring_until = models.DateTimeField(null=True, blank=True, default=None)
|
||||||
|
|
||||||
created_time = models.DateTimeField(auto_now_add=True)
|
created_time = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""String representation."""
|
"""Summarize object."""
|
||||||
return "{0:s} @ {1:s}".format(self.name, timezone.localtime(self.at_time).strftime('%Y-%m-%d %H:%M:%S %Z'))
|
return "{0:s} @ {1:s}".format(self.name, timezone.localtime(self.at_time).strftime('%Y-%m-%d %H:%M:%S %Z'))
|
||||||
|
14
countdown/serializers.py
Normal file
14
countdown/serializers.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
"""REST serializers for countdown items."""
|
||||||
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from countdown.models import CountdownItem
|
||||||
|
|
||||||
|
|
||||||
|
class CountdownItemSerializer(serializers.ModelSerializer):
|
||||||
|
"""Countdown item serializer for the REST API."""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
"""Meta options."""
|
||||||
|
|
||||||
|
model = CountdownItem
|
||||||
|
fields = '__all__'
|
12
countdown/urls.py
Normal file
12
countdown/urls.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
"""URL patterns for the countdown views."""
|
||||||
|
from django.conf.urls import include, url
|
||||||
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
from countdown.views import CountdownItemViewSet
|
||||||
|
|
||||||
|
router = DefaultRouter()
|
||||||
|
router.register(r'items', CountdownItemViewSet)
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
url(r'^api/', include(router.urls)),
|
||||||
|
]
|
16
countdown/views.py
Normal file
16
countdown/views.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""Provide an interface to countdown items."""
|
||||||
|
# from rest_framework.decorators import action
|
||||||
|
# from rest_framework.response import Response
|
||||||
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
from rest_framework.viewsets import ReadOnlyModelViewSet
|
||||||
|
|
||||||
|
from countdown.models import CountdownItem
|
||||||
|
from countdown.serializers import CountdownItemSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class CountdownItemViewSet(ReadOnlyModelViewSet):
|
||||||
|
"""Provide list and detail actions for countdown items."""
|
||||||
|
|
||||||
|
queryset = CountdownItem.objects.all()
|
||||||
|
serializer_class = CountdownItemSerializer
|
||||||
|
permission_classes = [IsAuthenticated]
|
@ -1,11 +1,9 @@
|
|||||||
"""General/baselite/site-wide URLs."""
|
"""General/baselite/site-wide URLs."""
|
||||||
|
from adminplus.sites import AdminSitePlus
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
from adminplus.sites import AdminSitePlus
|
|
||||||
|
|
||||||
admin.site = AdminSitePlus()
|
admin.site = AdminSitePlus()
|
||||||
admin.sites.site = admin.site
|
admin.sites.site = admin.site
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
@ -13,6 +11,7 @@ admin.autodiscover()
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', TemplateView.as_view(template_name='index.html'), name='index'),
|
url(r'^$', TemplateView.as_view(template_name='index.html'), name='index'),
|
||||||
|
|
||||||
|
url(r'^countdown/', include('countdown.urls')),
|
||||||
url(r'^dice/', include('dice.urls')),
|
url(r'^dice/', include('dice.urls')),
|
||||||
url(r'^dispatch/', include('dispatch.urls')),
|
url(r'^dispatch/', include('dispatch.urls')),
|
||||||
url(r'^itemsets/', include('facts.urls')),
|
url(r'^itemsets/', include('facts.urls')),
|
||||||
|
@ -13,13 +13,13 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='pilog',
|
model_name='pilog',
|
||||||
name='simulation_x',
|
name='simulation_x',
|
||||||
field=models.DecimalField(decimal_places=10, default=0.0, max_digits=11),
|
field=models.DecimalField(decimal_places=10, default=-1.0, max_digits=11),
|
||||||
preserve_default=False,
|
preserve_default=False,
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='pilog',
|
model_name='pilog',
|
||||||
name='simulation_y',
|
name='simulation_y',
|
||||||
field=models.DecimalField(decimal_places=10, default=0.0, max_digits=11),
|
field=models.DecimalField(decimal_places=10, default=-1.0, max_digits=11),
|
||||||
preserve_default=False,
|
preserve_default=False,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user