Example #1
0
def role_stats(role):
    res = {
        'role': role,
        'total': Attendee.objects(role=role).count(),
        'logged': Attendee.objects(role=role, first_use__ne=None).count(),
        'scenarios': []
    }

    for scenario in scenarios_def[role]:
        query_enabled_args = {
            'role': role,
            'scenario__{}__disabled'.format(scenario): None
        }

        query_used_args = {
            'role': role,
            'scenario__{}__used__ne'.format(scenario): None
        }

        res['scenarios'].append({
            'scenario': scenario,
            'enabled': Attendee.objects(**query_enabled_args).count(),
            'used': Attendee.objects(**query_used_args).count()
        })

    return res
Example #2
0
    def register(self, message, first, last, email):
        ''' register first last email '''
        
        attendee = Attendee(first_name=first, \
                                last_name=last, \
                                email=email, \
                                number=message.peer)
        try:
            attendee.save()
        except IntegrityError:
            att2 = Attendee.objects.get(number=message.peer)
            message.respond("Desole, ce numero est deja enregistre " \
                            "pour %s" % att2)
            return True

        message.respond(u"Merci %(att)s. Vous etes bien enregistré." % {'att': attendee})

        return True
Example #3
0
def dashboard_type(type):

    if type not in scenarios_def:
        raise Error('type required')

    scenarios = scenarios_def[type]

    req_fields = ['event_id', 'user_id', 'attr'] \
            + list(map(lambda str: 'scenario__' + str + '__used', scenarios)) \
            + list(map(lambda str: 'scenario__' + str + '__attr', scenarios)) \

    return jsonify(Attendee.objects(type=type).only(*req_fields))
Example #4
0
def get_attendee(request):
    token = request.args.get('token')

    if token is None:
        raise Error("token required")

    try:
        attendee = Attendee.objects(token=token).get()
    except DoesNotExist:
        raise Error("invalid token")

    return attendee
Example #5
0
def dashboard_role(role):

    if role not in scenarios_def:
        raise Error('role required')

    scenarios = scenarios_def[role]

    req_fields = ['event_id', 'user_id', 'attr'] + \
        list(map(lambda str: 'scenario__' + str + '__used', scenarios)) + \
        list(map(lambda str: 'scenario__' + str + '__attr', scenarios)) \

    return jsonify(Attendee.objects(role=role).only(*req_fields))
Example #6
0
def get_attendee(request):
    token = request.args.get('token')

    if token is None:
        raise Error("token required")

    try:
        attendee = Attendee.objects(token=token).get()
    except DoesNotExist:
        raise Error("invalid token")

    return attendee
Example #7
0
def list_import(attendee_list, scenarios):
    for row in attendee_list:
        attendee = Attendee()
        attendee.event_id = os.environ['EVENT_ID']
        attendee.token = row['token']
        if row['id'] == '':
            attendee.user_id = row['name']
        else:
            attendee.user_id = row['id']

        attendee.role = "audience"

        bind_scenario(row, attendee, scenarios)
Example #8
0
def register():
    if not is_registration_active():
        flash("Rejestracja już się skończyła dziękujemy za zaintersowania!")
        return redirect('/')
    form = RegisterForm(request.form)
    languages = [
        'Python', 'Ruby', 'C++',
        'Java', 'JavaScript', 'HTML/CSS',
        'Inny',
    ]
    i = random.randint(2, 5)
    text = '{} + {} * {} = ?'.format(i, i, i)
    form.i_am_human.label = text
    for lan in languages:
        form.exp.append_entry(data={'name': lan})
    if request.method == 'POST' and form.validate():
        new_attende = Attendee()
        form.populate_obj(new_attende)
        experience = {
            lan: request.form[lan] for lan in languages
            }
        new_attende.experience = json.dumps(experience)
        db.session.add(new_attende)
        db.session.commit()
        msg = Message(
            'Potwierdzenie rejestracji na warsztaty PyCode Carrots Poznań',
            recipients=[request.form.get('email')],
            html=EMAIL_CONFIRMATION
        )
        mail.send(msg)
        flash(
            'Twoja odpowiedź została zapisana. '
            'Powinieneś dostać potwierdzenie na podany e-mail.'
        )
        return redirect(url_for('register'))
    return render_template('register.html', form=form)
Example #9
0
def do_deliver_puzzle():
    token = request.args.get('token')
    receiver = request.form.get('receiver')

    if token is None or receiver is None:
        raise Error("token and receiver required")

    try:
        attendee = Attendee.objects(token=receiver).get()
    except DoesNotExist:
        raise Error("invalid receiver token")

    if token in delivery_permission.keys():
        deliver_puzzle(attendee, delivery_permission[token])
        app.logger.info(delivery_permission[token] + ' ' + token + ' deliver puzzle to ' + attendee.token)
        return jsonify({'status': 'OK'})
    else:
        raise Error("invalid token")
Example #10
0
def list_import(attendee_list, scenarios):
    for row in attendee_list:
        attendee = Attendee()
        attendee.event_id = os.environ['EVENT_ID']
        attendee.token = row['token']
        if row['id'] == '':
            attendee.user_id = row['name']
        else:
            attendee.user_id = row['id']

        attendee.type = "audience"

        bind_scenario(row, attendee, scenarios)
Example #11
0
def staff_import(attendee_list, scenarios):
    for row in attendee_list:
        attendee = Attendee()
        attendee.event_id = os.environ['EVENT_ID']
        attendee.token = row['username']
        attendee.user_id = row['display_name']
        teams = row['groups'].split(',')

        try:
            teams.remove('工作人員')
            teams.remove('組長')
            teams.remove('股長')
        except ValueError:
            pass

        attendee.role = "speaker" if "講者" in teams else "staff"

        attendee.attr['teams'] = teams
        attendee.attr['title'] = row['title']

        bind_scenario(row, attendee, scenarios)
Example #12
0
def staff_import(attendee_list, scenarios):
    for row in attendee_list:
        attendee = Attendee()
        attendee.event_id = os.environ['EVENT_ID']
        attendee.token = row['username']
        attendee.user_id = row['display_name']
        teams = row['groups'].split(',')

        try:
            teams.remove('工作人員')
            teams.remove('組長')
            teams.remove('股長')
        except ValueError:
            pass

        attendee.type = "speaker" if "講者" in teams else "staff"

        attendee.attr['teams'] = teams
        attendee.attr['title'] = row['title']

        bind_scenario(row, attendee, scenarios)
Example #13
0
def announcement():
    if request.method == 'GET':
        token = request.args.get('token')
        role = config.ANNOUNCEMENT_DEFAULT_ROLE

        if token is not None:
            try:
                attendee = Attendee.objects(token=token).get()
                role = attendee.role
            except DoesNotExist:
                raise Error("invalid token")

        return jsonify(Announcement.objects(role=role).order_by('-_id'))

    if request.method == 'POST':
        announcement = Announcement()
        announcement.datetime = time.time()
        announcement.msg_zh = request.form.get('msg_zh')
        announcement.msg_en = request.form.get('msg_en')
        announcement.uri = request.form.get('uri')
        announcement.role = request.form.getlist('role[]')
        announcement.save()

        return jsonify({'status': 'OK'})
Example #14
0
def dashboard():
    res = {}
    res['total'] = Attendee.objects().count()
    res['day1checkin_used'] = Attendee.objects(
        scenario__day1checkin__used__ne=None).count()
    res['kit_used'] = Attendee.objects(scenario__kit__used__ne=None).count()
    res['day1lunch'] = {
        'total':
        Attendee.objects(Q(scenario__day1checkin__used__ne=None)).count(),
        'meat':
        Attendee.objects(
            Q(scenario__day1checkin__attr__diet="meat")
            & Q(scenario__day1checkin__used__ne=None)).count(),
        'vegetarian':
        Attendee.objects(
            Q(scenario__day1checkin__attr__diet="vegetarian")
            & Q(scenario__day1checkin__used__ne=None)).count()
    }
    res['day2checkin_used'] = Attendee.objects(
        scenario__day2checkin__used__ne=None).count()
    res['day2lunch'] = {
        'total':
        Attendee.objects(Q(scenario__day2checkin__used__ne=None)).count(),
        'meat':
        Attendee.objects(
            Q(scenario__day2checkin__attr__diet="meat")
            & Q(scenario__day2checkin__used__ne=None)).count(),
        'vegetarian':
        Attendee.objects(
            Q(scenario__day2checkin__attr__diet="vegetarian")
            & Q(scenario__day2checkin__used__ne=None)).count()
    }
    res['day3checkin_used'] = Attendee.objects(
        scenario__day3checkin__used__ne=None).count()
    res['day3lunch'] = {
        'total':
        Attendee.objects(Q(scenario__day3checkin__used__ne=None)).count(),
        'meat':
        Attendee.objects(
            Q(scenario__day3checkin__attr__diet="meat")
            & Q(scenario__day3checkin__used__ne=None)).count(),
        'vegetarian':
        Attendee.objects(
            Q(scenario__day3checkin__attr__diet="vegetarian")
            & Q(scenario__day3checkin__used__ne=None)).count()
    }
    res['vipkit'] = {
        'total': Attendee.objects(scenario__vipkit__ne=None).count(),
        'used': Attendee.objects(scenario__vipkit__used__ne=None).count()
    }
    res['logged'] = Attendee.objects().count() - Attendee.objects(
        first_use=None).count()

    return jsonify(res)
Example #15
0
def dashboard():
    res = {}
    res['total'] = Attendee.objects().count()
    res['day1checkin_used'] = Attendee.objects(scenario__day1checkin__used__ne=None).count()
    res['kit_used'] = Attendee.objects(scenario__kit__used__ne=None).count()
    res['day1lunch'] = {
        'total': Attendee.objects(Q(scenario__day1lunch__disabled=None) | Q(scenario__day1lunch__disabled="Please use your badge")).count(),
        'meat': Attendee.objects(Q(scenario__day1lunch__attr__diet="meat") & (Q(scenario__day1lunch__disabled="Please use your badge") | Q(scenario__day1lunch__disabled=None))).count(),
        'vegetarian': Attendee.objects(Q(scenario__day1lunch__attr__diet="vegetarian") & (Q(scenario__day1lunch__disabled="Please use your badge") | Q(scenario__day1lunch__disabled=None))).count(),
        'meat_used': Attendee.objects(scenario__day1lunch__attr__diet="meat", scenario__day1lunch__used__ne=None).count(),
        'vegetarian_used': Attendee.objects(scenario__day1lunch__attr__diet="vegetarian", scenario__day1lunch__used__ne=None).count(),
    }
    res['day2checkin_used'] = Attendee.objects(scenario__day2checkin__used__ne=None).count()
    res['day2lunch'] = {
        'total': Attendee.objects(Q(scenario__day2lunch__disabled=None) | Q(scenario__day2lunch__disabled="Please use your badge")).count(),
        'meat': Attendee.objects(Q(scenario__day2lunch__attr__diet="meat") & (Q(scenario__day2lunch__disabled="Please use your badge") | Q(scenario__day2lunch__disabled=None))).count(),
        'vegetarian': Attendee.objects(Q(scenario__day2lunch__attr__diet="vegetarian") & (Q(scenario__day2lunch__disabled="Please use your badge") | Q(scenario__day2lunch__disabled=None))).count(),
        'meat_used': Attendee.objects(scenario__day2lunch__attr__diet="meat", scenario__day2lunch__used__ne=None).count(),
        'vegetarian_used': Attendee.objects(scenario__day2lunch__attr__diet="vegetarian", scenario__day2lunch__used__ne=None).count(),
    }
    res['vipkit'] = {
        'total': Attendee.objects(scenario__vipkit__disabled=None).count(),
        'used': Attendee.objects(scenario__vipkit__used__ne=None).count()
    }
    res['logged'] = Attendee.objects(first_use=not None).count()

    return jsonify(res)