Репозитория нет у этого конкретного проекта, могу просто кусками вываливать нужные куски кода =)
models.py
class BookingWrap(CMSPlugin):
room_name = models.CharField(max_length=100, blank=False)
color = models.CharField(choices=(('red', 'red'), ('blue', 'blue')), max_length=4, blank=False, default='blue')
def __str__(self):
return '%s' % (self.room_name)
class BookingDay(CMSPlugin):
day = models.CharField(choices=(('monday', 'Monday'),
('tuesday', 'Tuesday'),
('wednesday', 'Wednesday'),
('thursday', 'Thursday'),
('friday', 'Friday'),
('saturday', 'Saturday'),
('sunday', 'Sunday'),),
max_length=40)
def __str__(self):
return self.day
class BookingItem(CMSPlugin):
time = models.CharField(verbose_name="Time", max_length=40)
minutes = models.CharField(choices=(('45', '45'), ('60', '60'), ('90', '90')), max_length=40)
classname = models.ForeignKey(ClassPluginModel, on_delete=models.CASCADE, default="")
def __str__(self):
return '%s, %s, %s, %s' % (self.time, self.minutes, self.classname, self.classname.teacher.title)
ну и совсем непритязательный cms_plugins.py
class BookingWrapPlugin(CMSPluginBase):
cache = False
name = 'Booking'
model = BookingWrap
render_template = "booking/_booking_wrap_.html"
allow_children = True
child_classes = [
'BookingDayPlugin',
]
def get_render_template(self, context, instance, placeholder):
adress = context['adress']
templates = {
"booking": "booking/_booking_wrap_.html",
"classes": "booking/_class_wrap_.html",
"teachers": "booking/_teachers_wrap_.html"
}
return templates[adress]
plugin_pool.register_plugin(BookingWrapPlugin)
class BookingDayPlugin(CMSPluginBase):
cache = False
name = 'Booking Day'
render_template = "booking/_booking_day_.html"
model = BookingDay
allow_children = True
child_classes = [
'BookingItemPlugin',
]
require_parent = True
parent_classes = [
'BookingWrapPlugin',
]
def get_render_template(self, context, instance, placeholder):
adress = context['adress']
templates = {
"booking": "booking/_booking_day_.html",
"classes": "booking/_class_day_.html",
"teachers": "booking/_booking_day_.html"
}
return templates[adress]
plugin_pool.register_plugin(BookingDayPlugin)
class BookingItemPlugin(CMSPluginBase):
cache=False
name='Booking Item'
require_parent = True
model = BookingItem
render_template = "booking/_booking_item_.html"
parent_classes = [
'BookingWrapPlugin',
'BookingDayPlugin',
]
def get_render_template(self, context, instance, placeholder):
adress = context['adress']
templates = {
"booking": "booking/_booking_item_.html",
"classes": "booking/_class_item_.html",
"teachers": "booking/_teachers_item_.html"
}
return templates[adress]
plugin_pool.register_plugin(BookingItemPlugin)
Updated 24 May 2016, 17:55 by red_s.