Ejemplo n.º 1
0
    def list_venues():
        form = VenueListForm()
        if form.is_submitted():
            if form.edit_venue.data and int(form.venue.data) > 0:
                return redirect(url_for_admin('edit_venue', venue_id=form.venue.data))
        if form.add_venue.data:
            return redirect(url_for_admin('edit_venue', venue_id="0"))
        form.populate_venue_list()

        return render_template('admin/venue_list.html', form=form, render_link=render_link)
Ejemplo n.º 2
0
 def add_player_to_event(event_id):
     form = AddPlayerForm()
     if form.is_submitted():
         if form.submit.data:
             if form.add_booking(event_id):
                 return redirect(url_for_admin('results_event', event_id=event_id))
             else:
                 return redirect(url_for_admin('add_player_to_event', event_id=event_id))
     else:
         form.populate_add_player(event_id)
     return render_template('admin/event_add_player.html', form=form, event=event_id)
Ejemplo n.º 3
0
 def results_vl_event(event_id):
     form = EventResultsForm()
     if form.is_submitted():
         if form.save_results.data:
             if form.save_event_results(event_id):
                 flash('results saved', 'success')
                 return redirect(url_for_admin('results_event', event_id=event_id))
         if form.add_player.data:
             return redirect(url_for_admin('add_player_to_event', event_id=event_id))
     else:
         form.populate_event_results(event_id)
     return render_template('admin/event_result.html', form=form, event=event_id, render_link=render_link)
Ejemplo n.º 4
0
    def list_news():
        form = NewsListForm()
        if form.is_submitted():
            if form.edit_news.data and form.news_item.data != '0':
                return redirect(
                    url_for_admin('edit_news', news_date=form.news_item.data))
        if form.add_news.data:
            return redirect(url_for_admin('edit_news', news_date='new'))
        form.populate_news_list()

        return render_template('admin/news_list.html',
                               form=form,
                               render_link=render_link)
Ejemplo n.º 5
0
    def list_members():
        form = MemberListForm()
        if form.is_submitted():
            if form.edit_member.data and int(form.member.data) > 0:
                return redirect(
                    url_for_admin('edit_member', member_id=form.member.data))
            if form.add_member.data:
                return redirect(url_for_admin('edit_member', member_id=0))
        form.populate_member_list()

        return render_template('admin/member_list.html',
                               form=form,
                               render_link=render_link)
Ejemplo n.º 6
0
 def edit_venue(venue_id):
     form = VenueDetailsForm()
     if form.is_submitted():
         if form.save.data or form.add_course.data or form.remove_course.data:
             if form.save_venue(venue_id):
                 flash('Venue saved', 'success')
                 return redirect(url_for_admin('venues_main'))
         if form.new_course.data:
             return redirect(url_for_admin('edit_course', venue_id=venue_id, course_id=0))
     if not form.is_submitted():
         form.populate_venue(venue_id)
     venue = venue_id if venue_id != 0 else "(new)"
     return render_template('admin/venue_details.html', venue_id=venue, form=form, render_link=render_link)
Ejemplo n.º 7
0
 def report_event(event_id):
     event = get_event(event_id)
     form = EventReportForm()
     if form.is_submitted():
         if form.save:
             MaintainEvents.save_report_page('static/event_report.html', event, form)
             flash('report saved', 'success')
             return redirect(url_for_admin('list_events', year=event.date.year))
     else:
         report_file = MaintainEvents.report_file_name(event.date)
         if not form.populate_event_report(event_id, report_file):
             flash('Results not yet available', 'warning')
             return redirect(url_for_admin('events_main', event_id=event_id))
     return render_template('admin/event_report.html', form=form, event=event_id)
Ejemplo n.º 8
0
 def show_help(subject):
     if subject == '':
         return redirect(url_for_admin('list_help'))
     form = HelpSubjectForm()
     if form.is_submitted():
         if form.save.data:
             m = form.save_help(subject)
             if m:
                 flash('Help ' + m, 'success')
                 return redirect(url_for_admin('list_help'))
         if form.add_item.data:
             form.add_news_item()
     else:
         form.populate_help(subject)
     return render_template('admin/help.html', form=form, topic=subject)
Ejemplo n.º 9
0
    def list_events(year):
        form = EventListForm()
        if form.is_submitted():
            if form.publish_calendar.data:
                return redirect(url_for_admin('events_calendar', year=year))
            if form.add_event.data:
                event_type = EventType.wags_vl_event.value
            if form.add_tour.data:
                event_type = EventType.wags_tour.value
            if form.add_non_vl.data:
                event_type = EventType.non_vl_event.value
            if form.add_non.data:
                event_type = EventType.non_event.value
            return redirect(url_for_admin('edit_event', event_id=0, event_type=event_type))
        form.populate_event_list(int(year))

        return render_template('admin/event_list.html', form=form, render_link=render_link, EventType=EventType)
Ejemplo n.º 10
0
 def events_calendar(year):
     form = EventCalendarListForm()
     form.populate_calendar_event_list(int(year))
     csv = render_template('admin/event_calendar.txt', event_calendar_list=form.event_calendar_list)
     csv = csv.replace('\n\n', '\n').replace('\n\n', '\n')
     file = os.path.join(config.get('locations')['output'], 'calendar_' + year + '.csv')
     write_file(file, csv)
     flash('Calendar published as ' + file, 'success')
     return redirect(url_for_admin('list_events', year=year))
Ejemplo n.º 11
0
def upload_file(member_id):
    form = MinutesAdminForm()
    if form.validate_on_submit():
        if form.submit.data:
            if form.upload_minutes(member_id):
                flash('Draft minutes uploaded successfully, committee emailed',
                      'success')
                return redirect(url_for_admin('index'))
        if form.publish.data:
            if form.publish_minutes(member_id):
                flash('Minutes published successfully', 'success')
                return redirect(url_for_admin('index'))
    elif form.errors:
        flash_errors(form)
    if not form.is_submitted():
        form.populate()

    return render_template('admin/minutes_admin.html', form=form)
Ejemplo n.º 12
0
 def handicaps_event(event_id):
     form = EventHandicapsForm()
     if form.is_submitted():
         if form.save_handicaps.data:
             if form.save_event_handicaps(event_id):
                 flash('Handicaps saved', 'success')
                 return redirect(url_for_admin('handicaps_event', event_id=event_id))
     else:
         form.populate_event_handicaps(event_id)
     return render_template('admin/event_handicap.html', form=form,  event_id=event_id, render_link=render_link)
Ejemplo n.º 13
0
 def edit_news(news_date):
     if news_date == '0':
         return redirect(url_for_admin('news_main'))
     form = NewsDayForm()
     if form.is_submitted():
         if form.save.data:
             m = form.save_news_day(news_date)
             if m:
                 flash('News ' + m, 'success')
                 return redirect(url_for_admin('news_main'))
         if form.add_item.data:
             form.add_news_item()
     else:
         form.populate_news_day(news_date)
     title = 'News ' + news_date
     return render_template('admin/news_day.html',
                            title=title,
                            form=form,
                            render_link=render_link)
Ejemplo n.º 14
0
 def card_event_player(event_id, player_id, position='0', handicap=0, status=''):
     form = EventCardForm()
     if form.is_submitted():
         if form.save_card.data:
             if form.save_event_card(event_id, player_id, form):
                 flash('Card saved', 'success')
                 return redirect(url_for_admin('results_event', event_id=event_id))
     else:
         form.populate_card(event_id, player_id, position, handicap, status)
     return render_template('admin/event_card.html', form=form, event=event_id, render_link=render_link)
Ejemplo n.º 15
0
 def edit_course(venue_id, course_id):
     form = CourseCardForm()
     if form.validate_on_submit():
         add_new = False
         if form.add_new_card.data:
             add_new = True
         if form.save_course_card(venue_id, course_id, add_new):
             flash('card saved', 'success')
             return redirect(url_for_admin('edit_venue', venue_id=venue_id))
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         form.populate_card(course_id)
     return render_template('admin/course_card.html', form=form, render_link=render_link)
Ejemplo n.º 16
0
 def edit_member(member_id):
     form = MemberDetailsForm()
     form.member_id.data = member_id
     if form.validate_on_submit():
         if form.save.data:
             if form.save_member(member_id):
                 flash('member saved', 'success')
                 return redirect(url_for_admin('members_main'))
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         form.populate_member(member_id)
     return render_template('admin/member_details.html',
                            form=form,
                            render_link=render_link)
Ejemplo n.º 17
0
    def edit_event(event_id, event_type):
        form = EventForm()

        if form.is_submitted():
            if form.validate_on_submit():
                if form.save_event(event_id):
                    flash('Event saved', 'success')
                    year = form.date.data.year
                    return redirect(url_for_admin('list_events', year=year))
            else:
                form.populate_choices(event_id, event_type)
                event_type = EventType(coerce(form.event_type.data, int))
        else:
            form.populate_event(event_id, event_type)
            event_type = EventType(coerce(form.event_type.data, int))
        event = event_id if event_id != 0 else "(new)"
        event_type_desc = event_type.long_description()
        if event_type in [EventType.wags_vl_event, EventType.non_vl_event, EventType.cancelled]:
            return render_template('admin/event_details.html', form=form, event_id=event, event_type_desc=event_type_desc)
        if event_type in [EventType.wags_tour, EventType.minotaur]:
            return render_template('admin/tour_details.html', form=form, event_id=event, event_type_desc=event_type_desc)
        if event_type == EventType.non_event:
            return render_template('admin/non_event_details.html', form=form, event_id=event, event_type_desc=event_type_desc)