示例#1
0
def memberinfo_download(club):
    '''Download members' info'''
    info = []
    info.append(('Nick Name', 'Class', 'Passport Name', 'Email'))
    info.extend([(member.nickname, member.grade_and_class, member.passportname,
                  member.email) for member in club.members])
    return download_xlsx('Member Info.xlsx', info)
示例#2
0
def download_new_passwords():
    '''Allow admin to download new accounts' passwords'''
    result = []
    result.append(['Passport Name', 'Login Name', 'Class', 'Password'])
    users = User.get_new_passwords()
    result.extend([(user.passportname, user.studentid, user.grade_and_class,
                    password) for user, password in users])
    return download_xlsx('New Accounts\' Passwords.xlsx', result)
示例#3
0
def allusersinfo():
    '''Allow admin to download all users' info'''
    info = []
    info.append(
        ('ID', 'Class', 'Nick Name', 'Passport Name', 'Email', 'Phone'))
    info.extend([(user.id, user.grade_and_class, user.nickname,
                  user.passportname, user.email, str(user.phone))
                 for user in User.allusers()])

    return download_xlsx('All Users\' Info.xlsx', info)
示例#4
0
def attendance_download(activity):
    '''Download activity's attendance'''
    result = []
    result.append(('Nick Name', 'Class', 'Attendance'))
    attend, absent = partition(lambda member: member in activity.attendance,
                               activity.club.members)

    result.extend([(member.nickname, member.grade_and_class, 'Attended')
                   for member in attend])
    result.extend([(member.nickname, member.grade_and_class, 'Absent')
                   for member in absent])
    return download_xlsx('Attendance for ' + activity.name + '.xlsx', result)
示例#5
0
def thisweek_activitiesinfo():
    '''Allow admin to download this week's activities' info'''
    info = []
    info.append(
        ('Activity ID', 'Name', 'Club', 'Club Leader', 'Club Leader\'s Class',
         'Date', 'Time (Type)', 'Location', 'CAS Hours'))
    info.extend([
        (act.id, act.name, act.club.name, act.club.leader.passportname,
         act.club.leader.grade_and_class, act.date.strftime('%b-%d-%y'),
         act.time.format_name, act.location, act.cas)
        for act in Activity.thisweek_activities()
    ])
    return download_xlsx('This week\'s Activities\' Info.xlsx', info)
示例#6
0
def actstatus_download(activity):
    '''Download activity status'''
    info = []
    info.append([
        'Nick Name', 'Email', 'Phone', 'Consent Form',
        'Selection' if activity.selections else ''
    ])
    info.extend([
        (member['user'].nickname, member['user'].email,
         str(member['user'].phone),
         'Handed in' if member['consentform'] == 1 else 'Not handed in',
         member['selection'] if activity.selections else '')
        for member in activity.signup_list()
    ])
    return download_xlsx('Activity Status - ' + activity.name + '.xlsx', info)
示例#7
0
def allclubsinfo():
    '''Allow admin to download all clubs' info'''
    info = []
    info.append(('Club ID', 'Name', 'Leader', 'Leader\'s Class', 'Teacher',
                 'Introduction', 'Location', '# of Members',
                 '# of registered activities', '# of activities with attendance',
                 'Is Active or Not', 'Type', 'Description'))
    info.extend([(club.id, club.name, club.leader.passportname,
                  club.leader.grade_and_class,
                  club.teacher.email, club.intro, club.location,
                  len(club.members), len(club.activities()),
                  len(club.activities(require_attend=True)),
                  str(club.is_active),
                  club.type.format_name, club.description.raw)
                 for club in Club.allclubs()])

    return download_xlsx('All Clubs\' Info.xlsx', info)
示例#8
0
def hongmei_status_download(club):
    '''Download HongMei status'''
    result = []
    result.append(['Date', 'Members'])
    hongmei = club.activities([ActivityTime.HONGMEI], (False, True))
    for each in hongmei:
        result_each = []
        result_each.append(each.date.strftime('%b-%d-%y'))
        members = each.signup_list()
        members_result = ''
        for member in members:
            if member['consentform'] == 0:
                consentform = 'No'
            else:
                consentform = 'Yes'
            members_result += member['user'].nickname + ': ' \
                + str(member['user'].phone) + ' (Consent From Handed? ' \
                + consentform + ')\n'
        result_each.append(members_result)
        result.append(result_each)
    return download_xlsx('HongMei Status - ' + club.name + '.xlsx', result)
示例#9
0
def checkhongmeischedule_download():
    '''Allow admin to check HongMei schedule'''
    info = []
    try:
        actdate = date(int(request.form['year']), int(request.form['month']),
                       int(request.form['day']))
    except ValueError:
        fail('You have input wrong date for HongMei schedule.', 'status_info')
        return redirect(url_for('userblueprint.personal'))
    info.append((actdate.strftime('%b-%d-%Y'), ))
    info.append(('Club Name', 'Members'))
    for act in Activity.get_activities_conditions(
            times=(ActivityTime.HONGMEI, ), dates=actdate):
        members = ''

        members = '\n'.join(
            (member['user'].nickname + ': ' + str(member['user'].phone) +
             '(Consent From Handed? ' +
             ('Yes' if member['consentform'] == 1 else 'No') + ')')
            for member in act.signup_list())
        info.append((act.club.name, members))
    return download_xlsx(
        'HongMei\'s Schedule on ' + actdate.strftime('%b-%d-%Y') + '.xlsx',
        info)