fixes
This commit is contained in:
@@ -6,6 +6,7 @@ import traceback
|
||||
import ssl
|
||||
from datetime import datetime
|
||||
from sqlalchemy import desc
|
||||
from sqlalchemy import func
|
||||
from pathlib import Path
|
||||
|
||||
from smtplib import SMTP_SSL
|
||||
@@ -24,6 +25,7 @@ from werkzeug.security import generate_password_hash
|
||||
from . model import *
|
||||
|
||||
|
||||
|
||||
VALID_PROGRAMS = {'OS', 'SSG', 'MGP', 'ZG', 'NPI', 'SPI', 'SSI', 'PTI'}
|
||||
VALID_SUBJECTS = {'SLO', 'DJP', 'DDP', 'DNP', 'DSP', 'DIP'}
|
||||
VALID_TEXT_TYPES = {'E', 'PB', 'T', 'R'}
|
||||
@@ -491,6 +493,24 @@ def get_institution_upload_stats(institution_id):
|
||||
|
||||
return res
|
||||
|
||||
def get_region_stats():
|
||||
ret = {'CE': [0,0], 'GO': [0,0], 'KK': [0,0], 'KP': [0,0], 'KR': [0,0], 'LJ': [0,0], 'MB': [0,0], 'MS': [0,0], 'NM': [0,0], 'PO': [0,0], 'SG': [0,0]}
|
||||
|
||||
os = db.session.query(UploadSolar.region, func.count(UploadSolar.id)).filter_by(program="OS").group_by(UploadSolar.region).all()
|
||||
neos = db.session.query(UploadSolar.region, func.count(UploadSolar.id)).filter(sqlalchemy.not_(UploadSolar.program.contains("OS"))).group_by(UploadSolar.region).all()
|
||||
|
||||
#logging.error(os)
|
||||
#logging.error(neos)
|
||||
|
||||
for key, val in os:
|
||||
ret[key][0] = val
|
||||
for key, val in neos:
|
||||
ret[key][1] = val
|
||||
|
||||
logging.error(ret)
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
def get_all_active_users():
|
||||
# TODO: do filtering purely within an SQL query
|
||||
@@ -809,9 +829,11 @@ def get_actual_studentparent_contract_filename(f_hash):
|
||||
|
||||
|
||||
def get_password_reset_token(email, key, expires=600):
|
||||
return jwt.encode({'reset_password': email,
|
||||
token = jwt.encode({'reset_password': email,
|
||||
'exp': int(time.time()) + expires},
|
||||
key=key, algorithm='HS256')
|
||||
logging.error(token)
|
||||
return token
|
||||
|
||||
|
||||
def transfer_users_institution(institution_id_from, institution_id_to):
|
||||
@@ -860,7 +882,7 @@ def send_resetpass_mail(email, config):
|
||||
message = MIMEMultipart()
|
||||
message['From'] = config['MAIL_LOGIN']
|
||||
message['To'] = email
|
||||
message['Subject'] = 'Ponastavitev gesla'
|
||||
message['Subject'] = 'Portal Šolar: Ponastavitev gesla'
|
||||
message.attach(MIMEText(body, "plain"))
|
||||
text = message.as_string()
|
||||
|
||||
@@ -909,7 +931,7 @@ def send_user_activation_mail(user_id, config):
|
||||
message = MIMEMultipart()
|
||||
message['From'] = config['MAIL_LOGIN']
|
||||
message['To'] = user.email
|
||||
message['Subject'] = 'Ponastavitev gesla'
|
||||
message['Subject'] = 'Portal Šolar: Vaš uporabniški račun je odobren'
|
||||
message.attach(MIMEText(body, "plain"))
|
||||
text = message.as_string()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user