Skip to content

Commit

Permalink
http://luc.lino-framework.org/blog/2018/1129.html
Browse files Browse the repository at this point in the history
  • Loading branch information
lsaffre committed Nov 29, 2018
1 parent ca51d87 commit 394ab28
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lino_tera/lib/cal/__init__.py
Expand Up @@ -18,7 +18,7 @@

class Plugin(Plugin):

extends_models = ['Event', 'Guest']
extends_models = ['Event', 'Guest', 'GuestRole']

def setup_main_menu(self, site, user_type, m):
super(Plugin, self).setup_main_menu(site, user_type, m)
Expand Down
12 changes: 10 additions & 2 deletions lino_tera/lib/cal/models.py
Expand Up @@ -168,8 +168,15 @@ def force_guest_states(self):
# ref name id
# cal.GuestsByRole #courses.EnrolmentsByGuestRole
# """



class GuestRole(GuestRole):

class Meta(GuestRole.Meta):
abstract = dd.is_abstract_model(__name__, 'GuestRole')

is_teacher = dd.BooleanField(dd.plugins.courses.teacher_label, default=False)


class Guest(Guest):

class Meta(Guest.Meta):
Expand Down Expand Up @@ -230,6 +237,7 @@ class EventInsert(EventInsert):

GuestsByEvent.column_names = 'partner role workflow_buttons amount #payment_mode *'

GuestRoles.column_names = "ref name is_teacher *"

# class MyGuestsPayments(MyGuests):

Expand Down
17 changes: 15 additions & 2 deletions lino_tera/lib/courses/desktop.py
Expand Up @@ -83,6 +83,16 @@ class EnrolmentsByPupil(EnrolmentsByPupil):
remark
request_date user
"""
from lino.core.actions import ShowInsert

class ShowInsertColleague(ShowInsert):
help_text = _("Add a colleague")

def create_instance(self, ar):
obj = super(ShowInsertColleague, self).create_instance(ar)
# temporary solution with hard-coded pk:
obj.guest_role = rt.models.cal.GuestRole.objects.filter(is_teacher=True).first()
return obj


class EnrolmentsByCourse(EnrolmentsByCourse):
Expand All @@ -100,6 +110,8 @@ class EnrolmentsByCourse(EnrolmentsByCourse):
# request_date user
"""

show_insert2 = ShowInsertColleague()

class EnrolmentsAndPaymentsByCourse(Enrolments):
"""Show enrolments of a course together with
:attr:`payment_info`.
Expand All @@ -118,7 +130,7 @@ class EnrolmentsByLifeGroup(EnrolmentsByCourse):
'remark ' \
'workflow_buttons *'
insert_layout = """
pupil guest_role
pupil guest_role
# places option
remark
# request_date user
Expand All @@ -130,7 +142,7 @@ class EnrolmentsByTherapy(EnrolmentsByLifeGroup):
'workflow_buttons *'

insert_layout = """
pupil guest_role
pupil guest_role
# places option
remark
# request_date user
Expand Down Expand Up @@ -271,6 +283,7 @@ class ActivitiesByPartner(Courses):
master_key = 'partner'
column_names = "start_date overview workflow_buttons *"
order_by = ['-start_date']
display_mode = "html"

# class ActivitiesByClient(Activities):
# master_key = 'client'
Expand Down
2 changes: 1 addition & 1 deletion lino_tera/lib/tera/fixtures/demo.py
Expand Up @@ -137,7 +137,7 @@ def enrolments():

attendee = GuestRole(**dd.str2kw('name', _("Attendee")))
yield attendee
colleague = GuestRole(**dd.str2kw('name', _("Colleague")))
colleague = GuestRole(**dd.str2kw('name', _("Colleague"), is_teacher=True))
yield colleague

ind_et = EventType(
Expand Down

0 comments on commit 394ab28

Please sign in to comment.