Add a new button to activate user quickly
Remove password changing to avoid errors caused by auto-filling Change the time record to current time other than UTC time
This commit is contained in:
parent
4ba7d3c2da
commit
2b81f1963e
|
@ -95,7 +95,7 @@ class User(db.Model):
|
|||
if (date != None):
|
||||
self.register_date = date
|
||||
else:
|
||||
self.register_date = datetime.utcnow()
|
||||
self.register_date = datetime.now()
|
||||
self.user_group = usergroup
|
||||
self.auth_method = auth_method
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ def send_activated_email(to_address, username):
|
|||
<br><br>
|
||||
<p> <a href='http://docklet.unias.org'>Docklet Team</a>, SEI, PKU</p>
|
||||
''' % (env.getenv("PORTAL_URL"), env.getenv("PORTAL_URL"))
|
||||
text += '<p>'+ str(datetime.utcnow()) + '</p>'
|
||||
text += '<p>'+ str(datetime.now()) + '</p>'
|
||||
text += '</html>'
|
||||
subject = 'Docklet account activated'
|
||||
msg = MIMEMultipart()
|
||||
|
@ -107,7 +107,7 @@ def send_remind_activating_email(username):
|
|||
<br/><br/>
|
||||
<p> Docklet Team, SEI, PKU</p>
|
||||
''' % (username, env.getenv("PORTAL_URL"), env.getenv("PORTAL_URL"))
|
||||
text += '<p>'+ str(datetime.utcnow()) + '</p>'
|
||||
text += '<p>'+ str(datetime.now()) + '</p>'
|
||||
text += '</html>'
|
||||
subject = 'An activating request in Docklet has been sent'
|
||||
msg = MIMEMultipart()
|
||||
|
@ -769,6 +769,13 @@ class userManager:
|
|||
will send an e-mail when status is changed from 'applying' to 'normal'
|
||||
Usage: modify(newValue = dict_from_form, cur_user = token_from_auth)
|
||||
'''
|
||||
if ( kwargs['newValue'].get('Instruction', '') == 'Activate'):
|
||||
user_modify = User.query.filter_by(id = kwargs['newValue'].get('ID', None)).first()
|
||||
user_modify.status = 'normal'
|
||||
send_activated_email(user_modify.e_mail, user_modify.username)
|
||||
db.session.commit()
|
||||
return {"success": "true"}
|
||||
|
||||
user_modify = User.query.filter_by(username = kwargs['newValue'].get('username', None)).first()
|
||||
if (user_modify == None):
|
||||
|
||||
|
@ -786,11 +793,12 @@ class userManager:
|
|||
if (user_modify.status == 'applying' and form.get('status', '') == 'normal'):
|
||||
send_activated_email(user_modify.e_mail, user_modify.username)
|
||||
user_modify.status = form.get('status', '')
|
||||
if (form.get('password', '') != ''):
|
||||
new_password = form.get('password','')
|
||||
new_password = hashlib.sha512(new_password.encode('utf-8')).hexdigest()
|
||||
user_modify.password = new_password
|
||||
#if (form.get('password', '') != ''):
|
||||
#new_password = form.get('password','')
|
||||
#new_password = hashlib.sha512(new_password.encode('utf-8')).hexdigest()
|
||||
#user_modify.password = new_password
|
||||
#self.chpassword(cur_user = user_modify, password = form.get('password','no_password'))
|
||||
#modify password in another function now
|
||||
|
||||
db.session.commit()
|
||||
res = self.groupQuery(name=user_modify.user_group)
|
||||
|
|
|
@ -133,10 +133,10 @@
|
|||
<input type = "text" placeholder="Enter Telephone Number" class="form-control" name="tel" id="mTel">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<!--div class="form-group">
|
||||
<label>Password</label>
|
||||
<input type="password" placeholder="Enter Password" class="form-control" name="password" id="mPassword">
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
<div class="form-group">
|
||||
<label>User Group</label>
|
||||
|
@ -194,7 +194,12 @@
|
|||
"columnDefs": [
|
||||
{
|
||||
"render": function ( data, type, row ) {
|
||||
return '<a class="btn btn-info btn-sm" data-toggle="modal" data-target="#ModifyUserModal" onClick="javascript:setFormUser(' + row[0] + ');">' + 'Edit' + '</a>';
|
||||
str='<a class="btn btn-info btn-xs" data-toggle="modal" data-target="#ModifyUserModal" onClick="javascript:setFormUser(' + row[0] + ');">' + 'Edit' + '</a>';
|
||||
if (row[6]=='applying')
|
||||
{
|
||||
str=str + '<a class="btn btn-danger btn-xs" onClick="javascript:setActivateUser(' + row[0] + ');">' + 'Activate' + '</a>';
|
||||
}
|
||||
return str;
|
||||
},
|
||||
"targets": 8
|
||||
},
|
||||
|
@ -249,5 +254,15 @@
|
|||
$("#mDescription").val(result.description);
|
||||
});
|
||||
}
|
||||
function setActivateUser(arg){
|
||||
$.post("/user/change/",
|
||||
{
|
||||
ID: arg,
|
||||
Instruction: "Activate",
|
||||
},
|
||||
function(data,status){
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
@ -327,6 +327,11 @@ def useradd():
|
|||
def usermodify():
|
||||
return usermodifyView.as_view()
|
||||
|
||||
@app.route("/user/change/", methods=['POST'])
|
||||
@administration_required
|
||||
def userchange():
|
||||
return usermodifyView.as_view()
|
||||
|
||||
@app.route("/quota/add/", methods=['POST'])
|
||||
@administration_required
|
||||
def quotaadd():
|
||||
|
@ -545,4 +550,4 @@ if __name__ == '__main__':
|
|||
elif opt in ("-p", "--port"):
|
||||
webport = int(arg)
|
||||
|
||||
app.run(host = webip, port = webport, threaded=True)
|
||||
app.run(host = webip, port = webport, threaded=True,)
|
||||
|
|
Loading…
Reference in New Issue