Show affiliation in user and team pages in the admin panel (#1037)

* Show affiliation in user and team pages in the admin panel and public and private user and team pages. 
* Make user pages show team information (score, place) instead of user information if in team mode. 
* Make `Users.get_place()` and `Teams.get_place()` for return None instead of 0 if the account has no rank. (Closes #1039)
* Make `populate.py` randomly add affiliations and officials
This commit is contained in:
Kevin Chung
2019-07-12 07:14:08 -04:00
committed by GitHub
parent b453125726
commit 1c9e36fa8f
6 changed files with 114 additions and 33 deletions

View File

@@ -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)