def populate(form, member_id, edit=False): if not edit: set_select_field_new(form.choose_member, get_member_select_choices(), None, member_id) member = get_member(member_id) if member: player = member.player contact = member.contact form.status.data = member.status.name form.first_name.data = player.first_name form.last_name.data = player.last_name form.email.data = contact.email form.address.data = contact.address form.post_code.data = contact.post_code form.phone.data = contact.phone form.mugshot.data = url_for_html( 'pictures', 'mugshots', player.full_name().replace(' ', '_') + '.jpg')
def populate_venue(self, venue_id): self.editable.data = True venue = get_venue(venue_id) self.venue_id = venue.id self.name.data = venue.name self.directions.data = venue.directions course_choices = get_course_select_choices() set_select_field_new(self.select_course, course_choices, item_name='Course') if venue.contact: self.url.data = venue.contact.url self.phone.data = venue.contact.phone self.post_code.data = venue.contact.post_code self.address.data = venue.contact.address for course in venue.courses: item_form = VenueCourseForm() item_form.id = course.id item_form.name = course.name self.courses.append_entry(item_form)
def populate_choices(self, event_id, event_type): courses = get_course_select_choices() event = get_event(event_id) organiser = event.organiser.id if event.organiser else 0 trophy = event.trophy.id if event.trophy else 0 venue = event.venue.id if event.venue else 0 course = event.course.id if event.course else 0 set_select_field_new(self.organiser, get_member_select_choices(), default_selection=organiser, item_name='Organiser') set_select_field_new(self.trophy, get_trophy_select_choices(), default_selection=trophy, item_name='Trophy') set_select_field_new(self.venue, get_venue_select_choices(), default_selection=venue, item_name='Venue') if event_type in [ EventType.wags_vl_event, EventType.non_vl_event, EventType.non_event, EventType.cancelled ]: set_select_field_new(self.course, courses, default_selection=course, item_name='Course') if event_type in [EventType.wags_tour, EventType.minotaur]: item_count = 0 for item in event.tour_events + ( 6 - len(event.tour_events)) * [Event()]: course_id = item.course_id if item.course else 0 field = self.tour_schedule.entries[item_count].course set_select_field_new(field, courses, default_selection=course_id, item_name='Course') item_count += 1
def populate_member(self, member_id): new_member = member_id == 0 if new_member: self.first_name.data = 'new' self.last_name.data = 'member' self.status_return.data = MemberStatus.full_member.value self.handicap_return.data = 0 set_select_field_new(self.proposer, get_member_select_choices(), item_name='proposer') else: member = get_member(member_id) proposer = member.proposer_id if member.proposer else 0 set_select_field_new(self.proposer, get_member_select_choices(), default_selection=proposer, item_name='proposer') player = member.player contact = member.contact state = player.state_as_of(datetime.date.today()) set_select_field_new(self.status, MemberStatus.choices(), default_selection=member.status) self.status_return.data = member.status.value self.first_name.data = player.first_name self.last_name.data = player.last_name self.name_return.data = self.first_name.data + ' ' + self.last_name.data self.email.data = contact.email self.address.data = contact.address self.post_code.data = contact.post_code self.phone.data = contact.phone self.accepted_date.data = member.accepted or datetime.date( 1992, 6, 17) self.handicap_return.data = self.handicap.data = state.handicap self.as_of.data = state.date role = member.user.roles[-1].role if member.user else UserRole.user set_select_field_new(self.access, UserRole.choices(), default_selection=role)
def populate_event_select(self): set_select_field_new(self.event, get_event_select_list(), item_name='Event')