Пример #1
0
    def test_simple_or_award(self):
        simple_award = Award("tin",
                             "#f2f2f2",
                             {
                                 "or": {
                                     "action": 10,
                                     "virtual": 10,
                                     "networking": 10,
                                     "theory": 15
                                 }
                             })
        check_or = Award._check_or(simple_award.json()['points']['or'],
                                      {
                                          "action": 8,
                                          "virtual": 6,
                                          "networking": 11,
                                          "theory": 22
                                      }, [])
        full_award_check = Award._check_award_points(simple_award,
                                              {
                                                  "action": 8,
                                                  "virtual": 6,
                                                  "networking": 11,
                                                  "theory": 22
                                              })

        self.assertIn(check_or, ["networking", "theory"])
        self.assertTrue(full_award_check)
Пример #2
0
    def test_bronze_award(self):
        simple_award = Award(
            "bronze", "#cc4f55", {
                "and": [{
                    "or": {
                        "action": 40,
                        "practice": 40,
                        "networking": 40,
                        "theory": 42
                    },
                }, {
                    "or": {
                        "action": 40,
                        "practice": 40,
                        "networking": 40,
                        "theory": 42
                    }
                }]
            })

        full_award_check = Award._check_award_points(
            simple_award, {
                "action": 45,
                "virtual": 22,
                "practice": 39,
                "networking": 40,
                "theory": 1,
                "project": 70
            })

        self.assertEqual(full_award_check, True)
Пример #3
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)
Пример #4
0
    def test_simple_or_award(self):
        simple_award = Award("tin", "#f2f2f2", {
            "or": {
                "action": 10,
                "virtual": 10,
                "networking": 10,
                "theory": 15
            }
        })
        check_or = Award._check_or(simple_award.json()['points']['or'], {
            "action": 8,
            "virtual": 6,
            "networking": 11,
            "theory": 22
        }, [])
        full_award_check = Award._check_award_points(simple_award, {
            "action": 8,
            "virtual": 6,
            "networking": 11,
            "theory": 22
        })

        self.assertIn(check_or, ["networking", "theory"])
        self.assertTrue(full_award_check)
Пример #5
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")
Пример #6
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)
Пример #7
0
    def test_bronze_award(self):
        simple_award = Award("bronze",
                             "#cc4f55",
                             {
                                 "and": [
                                     {
                                         "or":
                                             {
                                                 "action": 40,
                                                 "practice": 40,
                                                 "networking": 40,
                                                 "theory": 42
                                             },
                                     },
                                     {
                                         "or":
                                             {
                                                 "action": 40,
                                                 "practice": 40,
                                                 "networking": 40,
                                                 "theory": 42
                                             }
                                     }
                                 ]
                             })

        full_award_check = Award._check_award_points(simple_award,
                                              {
                                                  "action": 45,
                                                  "virtual": 22,
                                                  "practice": 39,
                                                  "networking": 40,
                                                  "theory": 1,
                                                  "project": 70
                                              })

        self.assertEqual(full_award_check, True)
Пример #8
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")