-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* agenda today and goto buttons * link to agenda from closings admin view
- Loading branch information
Showing
4 changed files
with
94 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
from django.db import models | ||
from django.utils.timezone import localdate | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from rest_framework import serializers | ||
|
||
from experiments.models import Location | ||
|
||
|
||
class Closing(models.Model): | ||
start = models.DateTimeField(_('agenda:closing:attribute:start'), db_index=True) | ||
end = models.DateTimeField(_('agenda:closing:attribute:end'), db_index=True) | ||
start = models.DateTimeField(_("agenda:closing:attribute:start"), db_index=True) | ||
end = models.DateTimeField(_("agenda:closing:attribute:end"), db_index=True) | ||
|
||
# SET_NULL will let us keep closings history if for some reason a location is removed | ||
location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True, | ||
verbose_name=_('agenda:closing:attribute:location')) | ||
location = models.ForeignKey( | ||
Location, on_delete=models.SET_NULL, null=True, verbose_name=_("agenda:closing:attribute:location") | ||
) | ||
|
||
# used to indicate entire lab is closed | ||
is_global = models.BooleanField(_('agenda:cosing:attribute:is_global')) | ||
is_global = models.BooleanField(_("agenda:cosing:attribute:is_global")) | ||
|
||
comment = models.TextField(_("agenda:cosing:attribute:comment"), null=True) | ||
|
||
comment = models.TextField(_('agenda:cosing:attribute:comment'), null=True) | ||
@property | ||
def start_localdate(self): | ||
"""returns only the date part of self.start, but in the local timezone""" | ||
return localdate(self.start) | ||
|
||
|
||
class ClosingSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Closing | ||
fields = ['id', 'start', 'end', 'is_global', 'comment', 'location', | ||
'location_name'] | ||
fields = ["id", "start", "end", "is_global", "comment", "location", "location_name"] | ||
|
||
location_name = serializers.StringRelatedField(source='location') # type: ignore | ||
location = serializers.PrimaryKeyRelatedField(queryset=Location.objects.all(), | ||
allow_null=True) | ||
location_name = serializers.StringRelatedField(source="location") # type: ignore | ||
location = serializers.PrimaryKeyRelatedField(queryset=Location.objects.all(), allow_null=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters