Beispiel #1
0
 def select(title):
     form = QueryForm()
     form.set_status_choices()
     if form.submit.data:
         form.display_fields.data = [
             int(v) for v in form.display_fields.data
         ]
         if form.validate_on_submit():
             query_clauses = form.find_members()
             display_fields = [
                 c[1] for c in form.display_fields.choices
                 if c[0] in form.display_fields.data
             ]
             return redirect(
                 url_for('extracts_show',
                         type='query',
                         page=1,
                         query_clauses=url_pickle_dump(query_clauses),
                         display_fields=url_pickle_dump(display_fields)))
         elif form.errors:
             flash_errors(form)
     return render_template('query.html',
                            form=form,
                            render_link=render_link,
                            title=title)
Beispiel #2
0
 def diversity_member(member_number):
     redirect = MaintainMembers.current_user_is_member(member_number)
     if redirect:
         return redirect
     form = DiversityForm()
     if form.validate_on_submit():
         if form.submit.data:
             member = form.save_member(member_number)
             if member:
                 flash(
                     'member {} {}'.format(
                         member.dt_number(),
                         'saved' if member_number == 0 else 'updated'),
                     'success')
             form.populate_member(member_number,
                                  request.referrer,
                                  renewal=False)
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         message = form.populate_member(member_number,
                                        request.referrer,
                                        renewal=False)
         if message:
             flash(message, 'success')
     return render_template('diversity.html',
                            form=form,
                            render_link=render_link)
Beispiel #3
0
    def renewal_debit(member_number, upgrade):
        goto = MaintainMembers.current_user_is_member(member_number, 'renewal')
        if goto:
            return goto
        form = RenewalDebitForm()
        form.make_readonly('dt_number')
        form.make_readonly('amount')

        if form.validate_on_submit():
            member = None
            if form.submit.data:
                member = form.save(member_number)
            elif form.errors:
                flash_errors(form)
            if member:
                payment = member.last_payment()
                upgrade_text = ' upgrade' if upgrade else ''
                return render_template(
                    'renewal_acknowledge.html',
                    dt_number=member.dt_number(),
                    member_status=member.status.name,
                    payment_method=payment.method.name if payment else None,
                    dues=payment.amount if payment else None,
                    renewal_type=member.long_membership_type(upgrade=upgrade) +
                    upgrade_text)
        if not form.is_submitted():
            form.populate(member_number, upgrade)
        return render_template('renewal_dd.html',
                               form=form,
                               MembershipType=MembershipType,
                               render_link=render_link)
Beispiel #4
0
 def edit_member(member_number):
     redirect = MaintainMembers.current_user_is_member(member_number)
     if redirect:
         return redirect
     form = MemberEditForm()
     if form.validate_on_submit():
         if form.submit.data:
             payment_method, paypal_payment, dues, member_type, member = form.save_member(
                 member_number)
             if member:
                 flash(
                     'member {} {}'.format(
                         member.dt_number(),
                         'saved' if member_number == 0 else 'updated'),
                     'success')
             form.populate_member(member_number,
                                  request.referrer,
                                  renewal=False)
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         message = form.populate_member(member_number,
                                        request.referrer,
                                        renewal=False)
         if message:
             flash(message, 'success')
     return render_template('renewal.html',
                            form=form,
                            MembershipType=MembershipType,
                            render_link=render_link)
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
0
 def find_members():
     form = MemberListForm()
     form.set_status_choices()
     form.set_membership_type_choices()
     form.set_initial_counts()
     if form.validate_on_submit():
         query_clauses = form.find_members()
         return redirect(
             url_for('members',
                     query_clauses=url_pickle_dump(query_clauses)))
     elif form.errors:
         flash_errors(form)
     return render_template('member_list.html',
                            form=form,
                            render_link=render_link)
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)
Beispiel #9
0
    def bulk_update():
        form = QueryForm()
        form.set_status_choices()
        if form.validate_on_submit():
            if form.submit.data:
                query_clauses = url_pickle_load(
                    request.args.get('query_clauses'))
                query = get_members_for_query(query_clauses)
                updates = form.get_updates()
                # ToDo: update here
                # flash updated
                return  ##redirect(url_for('extracts_bulk_update', query_clauses=query_clauses))
        elif form.errors:
            flash_errors(form)

        return render_template('query.html',
                               form=form,
                               render_link=render_link,
                               title='Bulk update')
Beispiel #10
0
 def copy_member(member_number):
     form = MemberDetailsForm()
     if form.validate_on_submit():
         if form.submit.data:
             member_number = 0
             member = form.save_member(member_number)
             if member:
                 flash(
                     'member {} {}'.format(
                         member.dt_number(),
                         'saved' if member_number == 0 else 'updated'),
                     'success')
                 return redirect(form.return_url.data)
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         form.populate_member(member_number, request.referrer, copy=True)
     return render_template('member_details.html',
                            form=form,
                            render_link=render_link)
Beispiel #11
0
 def edit_or_view_member(member_number):
     form = MemberDetailsForm()
     if form.validate_on_submit():
         if form.submit.data:
             member = form.save_member(member_number)
             if member:
                 flash(
                     'member {} {}'.format(
                         member.dt_number(),
                         'saved' if member_number == 0 else 'updated'),
                     'success')
                 return redirect(form.return_url.data)
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         form.populate_member(member_number, request.referrer)
         if not current_user.has_write_access():
             read_only_form(form)
     return render_template('member_details.html',
                            form=form,
                            render_link=render_link)
Beispiel #12
0
 def renew_member(member_number):
     goto = MaintainMembers.current_user_is_member(member_number, 'renewal')
     if goto:
         return goto
     form = MemberEditForm()
     if form.validate_on_submit():
         if form.submit.data:
             previous_payment_method = PaymentMethod.from_value(
                 int(form.previous_payment_method.data))
             payment_method, renewal_payment, dues, member_type, member = form.save_member(
                 member_number)
             logout = True
             if member:
                 flash(
                     'member {} {}'.format(
                         member.dt_number(),
                         'saved' if member_number == 0 else 'updated'),
                     'success')
                 if renewal_payment and payment_method == PaymentMethod.cc:
                     next = render_template(
                         'renewal_paypal.html',
                         pp_name=renewal_payment.name.replace("_", " "),
                         pp_value=renewal_payment.value,
                         dt_number=member.dt_number(),
                         concession_type=member.concession_type())
                 elif renewal_payment and payment_method == PaymentMethod.dd and previous_payment_method != PaymentMethod.dd:
                     upgrade = member.last_action() and member.last_action(
                     ).action == MemberAction.upgrade
                     next = redirect(
                         full_url('members/{}/renewal/dd?upgrade={}'.format(
                             member.number, upgrade or False)))
                     logout = False
                 elif renewal_payment and payment_method == PaymentMethod.chq:
                     upgrade = member.last_action() and member.last_action(
                     ).action == MemberAction.upgrade
                     next = redirect(
                         full_url(
                             'members/{}/renewal/chq?upgrade={}'.format(
                                 member.number, upgrade or False)))
                     logout = False
                 else:
                     next = render_template(
                         'renewal_acknowledge.html',
                         dt_number=member.dt_number(),
                         member_status=member.status.name,
                         payment_method=payment_method.name
                         if payment_method else None,
                         dues=dues,
                         renewal_type=member_type)
                 if logout and current_user.role != UserRole.super:
                     logout_user()
                 return next
             form.populate_member(member_number,
                                  request.referrer,
                                  renewal=True)
     elif form.errors:
         flash_errors(form)
     if not form.is_submitted():
         message = form.populate_member(member_number,
                                        request.referrer,
                                        renewal=True)
         if message:
             flash(message, 'success')
     return render_template('renewal.html',
                            form=form,
                            MembershipType=MembershipType,
                            render_link=render_link)