diff --git a/CTFd/models/__init__.py b/CTFd/models/__init__.py index 3ac203f..a40c66e 100644 --- a/CTFd/models/__init__.py +++ b/CTFd/models/__init__.py @@ -358,7 +358,7 @@ class Users(db.Model): k = i % 10 return "%d%s" % (i, "tsnrhtdd"[(i / 10 % 10 != 1) * (k < 4) * k :: 4]) except ValueError: - return 0 + return None class Admins(Users): @@ -486,7 +486,7 @@ class Teams(db.Model): k = i % 10 return "%d%s" % (i, "tsnrhtdd"[(i / 10 % 10 != 1) * (k < 4) * k :: 4]) except ValueError: - return 0 + return None class Submissions(db.Model): diff --git a/CTFd/themes/admin/templates/teams/team.html b/CTFd/themes/admin/templates/teams/team.html index 90fd148..566bc3b 100644 --- a/CTFd/themes/admin/templates/teams/team.html +++ b/CTFd/themes/admin/templates/teams/team.html @@ -57,6 +57,10 @@ {% endif %} + {% if team.affiliation %} +

{{ team.affiliation }}

+ {% endif %} +

{{ members | length }} members

{% if place %} diff --git a/CTFd/themes/admin/templates/users/user.html b/CTFd/themes/admin/templates/users/user.html index 38c03aa..7cfb856 100644 --- a/CTFd/themes/admin/templates/users/user.html +++ b/CTFd/themes/admin/templates/users/user.html @@ -70,6 +70,10 @@ {% endif %} + {% if user.affiliation %} +

{{ user.affiliation }}

+ {% endif %} +

{{ user.email }}

{% if user.oauth_id %} diff --git a/CTFd/themes/core/templates/users/private.html b/CTFd/themes/core/templates/users/private.html index 79a2d7d..d885766 100644 --- a/CTFd/themes/core/templates/users/private.html +++ b/CTFd/themes/core/templates/users/private.html @@ -8,6 +8,16 @@

{{ user.name }}

+ {% if user.team_id %} +

+ + + {{ user.team.name }} + + +

+ {% endif %} + {% if user.oauth_id %}

Official

@@ -18,22 +28,36 @@

{{ user.affiliation }}

{% endif %} - + {% if user.team_id %} +
+

+ {# This intentionally hides the user's place because this can be their internal profile. #} + {# Public page hiding is done at the route level #} + {% if scores_visible() and user.team.place %} + {{ user.team.place }} place + {% endif %} +

+

+ {{ user.team.score }} points +

+
+ {% else %} + + {% endif %}
{% if user.website and (user.website.startswith('http://') or user.website.startswith('https://')) %} diff --git a/CTFd/themes/core/templates/users/public.html b/CTFd/themes/core/templates/users/public.html index 79a2d7d..de0a99a 100644 --- a/CTFd/themes/core/templates/users/public.html +++ b/CTFd/themes/core/templates/users/public.html @@ -8,6 +8,16 @@

{{ user.name }}

+ {% if user.team_id %} +

+ + + {{ user.team.name }} + + +

+ {% endif %} + {% if user.oauth_id %}

Official

@@ -18,22 +28,39 @@

{{ user.affiliation }}

{% endif %} - + {% else %} + + {% endif %}
{% if user.website and (user.website.startswith('http://') or user.website.startswith('https://')) %} diff --git a/populate.py b/populate.py index 4ea2fe7..b60d6fd 100644 --- a/populate.py +++ b/populate.py @@ -184,6 +184,12 @@ extensions = [ '.jav', '.pl', '.bak', '.gho', '.old', '.ori', '.tmp', '.dmg', '.iso', '.toa', '.vcd', '.gam', '.nes', '.rom', '.sav', '.msi', ] +companies = [ + 'Corp', + 'Inc.', + 'Squad', + 'Team', +] def gen_sentence(): @@ -206,6 +212,10 @@ def gen_category(): return random.choice(categories) +def gen_affiliation(): + return (random.choice(hipsters) + " " + random.choice(companies)).title() + + def gen_value(): return random.choice(range(100, 500, 50)) @@ -223,6 +233,10 @@ def random_date(start, end): seconds=random.randint(0, int((end - start).total_seconds()))) +def random_chance(): + return random.random() > 0.5 + + if __name__ == '__main__': with app.app_context(): db = app.db @@ -274,6 +288,10 @@ if __name__ == '__main__': name=name, password="password" ) + if random_chance(): + team.affiliation = gen_affiliation() + if random_chance(): + team.oauth_id = random.randint(1, 1000) db.session.add(team) count += 1 @@ -295,6 +313,10 @@ if __name__ == '__main__': password='password' ) user.verified = True + if random_chance(): + user.affiliation = gen_affiliation() + if random_chance(): + user.oauth_id = random.randint(1, 1000) if mode == 'teams': user.team_id = random.randint(1, TEAM_AMOUNT) db.session.add(user)