59 lines
2.3 KiB
Python
59 lines
2.3 KiB
Python
# combo - content management system
|
|
# Copyright (C) 2017 Entr'ouvert
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import datetime
|
|
|
|
from django.db import models
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from combo.data.models import CellBase
|
|
from combo.data.library import register_cell_class
|
|
from .utils import (is_chrono_enabled, is_wcs_enabled,
|
|
add_paginated_calendar_to_context)
|
|
|
|
|
|
@register_cell_class
|
|
class BookingCalendar(CellBase):
|
|
|
|
title = models.CharField(_('Title'), max_length=128, blank=True, null=True)
|
|
agenda_reference = models.CharField(_('Agenda'), max_length=128)
|
|
formdef_reference = models.CharField(_('Form'), max_length=128)
|
|
slot_duration = models.DurationField(
|
|
_('Slot duration'), default=datetime.timedelta(minutes=30),
|
|
help_text=_('Format is hours:minutes:seconds'))
|
|
minimal_booking_duration = models.DurationField(
|
|
_('Minimal booking duration'), default=datetime.timedelta(hours=1),
|
|
help_text=_('Format is hours:minutes:seconds'))
|
|
days_displayed = models.PositiveSmallIntegerField(_('Number of days to display'), default=7)
|
|
|
|
template_name = 'calendar/booking_calendar_cell.html'
|
|
|
|
class Meta:
|
|
verbose_name = _('Booking Calendar')
|
|
|
|
def get_default_form_class(self):
|
|
from .forms import BookingCalendarForm
|
|
return BookingCalendarForm
|
|
|
|
@classmethod
|
|
def is_enabled(cls):
|
|
return is_chrono_enabled() and is_wcs_enabled()
|
|
|
|
def render(self, context):
|
|
context.update(self.get_cell_extra_context(context))
|
|
context = add_paginated_calendar_to_context(context)
|
|
return super(BookingCalendar, self).render(context)
|