server name config, top uploads for instituion, institution upload stats endpoint
This commit is contained in:
@@ -458,9 +458,9 @@ def get_top_uploading_institutions():
|
||||
return dict(sorted(res.items(), key=lambda x:x[1], reverse=True))
|
||||
|
||||
|
||||
def get_top_uploading_users():
|
||||
def get_top_uploading_users(institution_id):
|
||||
res = dict()
|
||||
users = get_all_active_users()
|
||||
users = get_all_active_institution_users(institution_id)
|
||||
for user in users:
|
||||
uploads = UploadSolar.query.filter_by(upload_user=user.id).all()
|
||||
for upload in uploads:
|
||||
@@ -472,6 +472,27 @@ def get_top_uploading_users():
|
||||
return dict(sorted(res.items(), key=lambda x:x[1], reverse=True))
|
||||
|
||||
|
||||
def get_institution_upload_stats(institution_id):
|
||||
res = {
|
||||
'region': [],
|
||||
'program': [],
|
||||
}
|
||||
|
||||
# Region
|
||||
for region in VALID_REGIONS:
|
||||
count = UploadSolar.query.filter_by(institution=institution_id, region=region).count()
|
||||
res['region'].append((region, count))
|
||||
res['region'] = sorted(res['region'], key=lambda x:x[1], reverse=True)
|
||||
|
||||
# Program
|
||||
for program in VALID_PROGRAMS:
|
||||
count = UploadSolar.query.filter_by(institution=institution_id, program=program).count()
|
||||
res['program'].append((program, count))
|
||||
res['program'] = sorted(res['program'], key=lambda x:x[1], reverse=True)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def get_all_active_users():
|
||||
# TODO: do filtering purely within an SQL query
|
||||
res = []
|
||||
@@ -785,8 +806,7 @@ def send_resetpass_mail(email, config):
|
||||
body = '''
|
||||
Zahtevali ste ponastavitev gesla vašega uporabniškega računa.
|
||||
|
||||
Geslo lahko ponastavite na naslednji povezavi: http://proc1.cjvt.si:5000/resetpass/{}'''.format(jwt_token)
|
||||
logging.info(body)
|
||||
Geslo lahko ponastavite na naslednji povezavi: https://{}/resetpass/{}'''.format(config['SERVER_NAME'], jwt_token)
|
||||
message = MIMEMultipart()
|
||||
message['From'] = config['MAIL_LOGIN']
|
||||
message['To'] = email
|
||||
|
||||
Reference in New Issue
Block a user