Exemplo n.º 1
0
def admin_view_profile(user_email):
    if session.contains('email') and session['email'] is not None:
        if User.get_user_permissions(session['email']) == 'admin':
            profile = User.find_by_email(user_email)
            events = profile.get_registered_events(profile.email)
            totalpoints = profile.total_points()
            attended_events = profile.get_all_attended(profile.email)
            current_date = datetime.now()
            permissions = User.get_user_permissions(session['email'])
            user_points = profile.data[
                'points'] if 'points' in profile.data.keys() else None
            awards = []
            if user_points is not None:
                awards = Award.check_user_awards(profile.data['points'])
            return render_template('user-profile.html',
                                   email=user_email,
                                   profile=profile,
                                   events=events,
                                   totalpoints=totalpoints,
                                   rank=profile.get_point_rank(),
                                   permissions=permissions,
                                   date=current_date,
                                   attended_events=attended_events,
                                   awards=awards)

    else:
        abort(401)
Exemplo n.º 2
0
def view_event_registrations(event_id):
    if session.contains('email') and session['email'] is not None:
        if User.get_user_permissions(session['email']) == 'admin':
            users = EventRegister.list_registered_users(event_id)
            return render_template('admin-event-registrations.html', users=users, event_id=event_id)
        else:
            abort(401)
Exemplo n.º 3
0
 def func_wrapper(*args, **kwargs):
     if session.contains('email') and session[
             'email'] is not None and User.find_by_email(
                 session['email']).allowed(type):
         return make_response(func(*args, **kwargs))
     else:
         abort(401)
Exemplo n.º 4
0
def edit_uni_page():
    if session.contains('email') and session['email'] is not None:
        if User.get_user_permissions(session['email']) == 'admin':
            universities = University.get_uni_list()
            return render_template('university-update.html', universities=universities)

    else:
        abort(401)
Exemplo n.º 5
0
def edit_uni_page():
    if session.contains('email') and session['email'] is not None:
        if User.get_user_permissions(session['email']) == 'admin':
            universities = University.get_uni_list()
            return render_template('university-update.html',
                                   universities=universities)

    else:
        abort(401)
Exemplo n.º 6
0
def view_event_registrations(event_id):
    if session.contains('email') and session['email'] is not None:
        if User.get_user_permissions(session['email']) == 'admin':
            users = EventRegister.list_registered_users(event_id)
            return render_template('admin-event-registrations.html',
                                   users=users,
                                   event_id=event_id)
        else:
            abort(401)
Exemplo n.º 7
0
def event_get(event_id):
    try:
        old_event = Event.get_by_id(event_id)
        registered = None

        if session.contains('email') and session['email'] is not None:
            registered = EventRegister.check_if_registered(session['email'], event_id)
        date = datetime.now()
        ff = old_event._end < date
        return render_template('items/event.html', event=old_event.to_json(), registered=registered, date=date)
    except NoSuchEventExistException:
        abort(404)
Exemplo n.º 8
0
def layout(response):
    if response.content_type == 'text/html; charset=utf-8' and 'static/' not in request.base_url:
        data = response.get_data()
        data = data.decode('utf-8')
        pages = Page.get_all()
        pages_json = []
        for page in pages:
            pages_json.append(page.to_json())
        if str(request.url_rule).startswith("/admin"):
            data = render_template('admin.html', access_level=get_access_level(), pages=pages_json, data=data,
                                   user=session['email'] if session.contains('email') and session[
                                                                                              'email'] is not None else None)
            data = render_template('layout.html', access_level=get_access_level(), pages=pages_json, data=data,
                                   user=session['email'] if session.contains('email') and session[
                                                                                              'email'] is not None else None)
        else:
            data = render_template('layout.html', access_level=get_access_level(), pages=pages_json, data=data,
                                   user=session['email'] if session.contains('email') and session[
                                                                                              'email'] is not None else None)
        response.set_data(data)
        response.direct_passthrough = False

        return response
    return response
Exemplo n.º 9
0
def layout(response):
    if response.content_type == 'text/html; charset=utf-8' and 'static/' not in request.base_url:
        data = response.get_data()
        data = data.decode('utf-8')
        pages = Page.get_all()
        pages_json = []
        for page in pages:
            pages_json.append(page.to_json())
        if str(request.url_rule).startswith("/admin"):
            data = render_template(
                'admin.html',
                access_level=get_access_level(),
                pages=pages_json,
                data=data,
                user=session['email'] if session.contains('email')
                and session['email'] is not None else None)
            data = render_template(
                'layout.html',
                access_level=get_access_level(),
                pages=pages_json,
                data=data,
                user=session['email'] if session.contains('email')
                and session['email'] is not None else None)
        else:
            data = render_template(
                'layout.html',
                access_level=get_access_level(),
                pages=pages_json,
                data=data,
                user=session['email'] if session.contains('email')
                and session['email'] is not None else None)
        response.set_data(data)
        response.direct_passthrough = False

        return response
    return response
Exemplo n.º 10
0
def event_get(event_id):
    try:
        old_event = Event.get_by_id(event_id)
        registered = None

        if session.contains('email') and session['email'] is not None:
            registered = EventRegister.check_if_registered(
                session['email'], event_id)
        date = datetime.now()
        ff = old_event._end < date
        return render_template('items/event.html',
                               event=old_event.to_json(),
                               registered=registered,
                               date=date)
    except NoSuchEventExistException:
        abort(404)
Exemplo n.º 11
0
def view_profile():
    if session.contains('email') and session['email'] is not None:
        profile = User.find_by_email(session['email'])
        events = profile.get_registered_events(session['email'])
        attended_events = profile.get_all_attended(session['email'])
        current_date = datetime.now()
        #current_date = current_date.strftime("%d-%m-%Y at %H:%M")
        totalpoints = profile.total_points()
        user_points = profile.data['points'] if 'points' in profile.data.keys() else None
        awards = []
        if user_points is not None:
            awards = Award.check_user_awards(profile.data['points'])

        return render_template('user-profile.html', profile=profile, events=events, attended_events=attended_events, totalpoints=totalpoints,
                               rank=profile.get_point_rank(), awards=awards, date=current_date)
    else:
        return render_template('user-profile.html', message="Not Logged In")
Exemplo n.º 12
0
def admin_view_profile(user_email):
    if session.contains('email') and session['email'] is not None:
        if User.get_user_permissions(session['email']) == 'admin':
            profile = User.find_by_email(user_email)
            events = profile.get_registered_events(profile.email)
            totalpoints = profile.total_points()
            attended_events = profile.get_all_attended(profile.email)
            current_date = datetime.now()
            permissions = User.get_user_permissions(session['email'])
            user_points = profile.data['points'] if 'points' in profile.data.keys() else None
            awards = []
            if user_points is not None:
                awards = Award.check_user_awards(profile.data['points'])
            return render_template('user-profile.html', email=user_email, profile=profile, events=events, totalpoints=totalpoints,
                                   rank=profile.get_point_rank(), permissions=permissions, date=current_date,
                                   attended_events=attended_events, awards=awards)

    else:
        abort(401)
Exemplo n.º 13
0
def view_profile():
    if session.contains('email') and session['email'] is not None:
        profile = User.find_by_email(session['email'])
        events = profile.get_registered_events(session['email'])
        attended_events = profile.get_all_attended(session['email'])
        current_date = datetime.now()
        #current_date = current_date.strftime("%d-%m-%Y at %H:%M")
        totalpoints = profile.total_points()
        user_points = profile.data['points'] if 'points' in profile.data.keys(
        ) else None
        awards = []
        if user_points is not None:
            awards = Award.check_user_awards(profile.data['points'])

        return render_template('user-profile.html',
                               profile=profile,
                               events=events,
                               attended_events=attended_events,
                               totalpoints=totalpoints,
                               rank=profile.get_point_rank(),
                               awards=awards,
                               date=current_date)
    else:
        return render_template('user-profile.html', message="Not Logged In")
Exemplo n.º 14
0
def get_access_level():
    if session.contains('email') and session['email'] is not None:
        return User.find_by_email(session['email']).permissions
    return ""
Exemplo n.º 15
0
 def func_wrapper(*args, **kwargs):
     if session.contains('email') and session['email'] is not None and User.find_by_email(
             session['email']).allowed(type):
         return make_response(func(*args, **kwargs))
     else:
         abort(401)
Exemplo n.º 16
0
def get_access_level():
    if session.contains('email') and session['email'] is not None:
        return User.find_by_email(session['email']).permissions
    return ""