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):
|
if (date != None):
|
||||||
self.register_date = date
|
self.register_date = date
|
||||||
else:
|
else:
|
||||||
self.register_date = datetime.utcnow()
|
self.register_date = datetime.now()
|
||||||
self.user_group = usergroup
|
self.user_group = usergroup
|
||||||
self.auth_method = auth_method
|
self.auth_method = auth_method
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ def send_activated_email(to_address, username):
|
||||||
<br><br>
|
<br><br>
|
||||||
<p> <a href='http://docklet.unias.org'>Docklet Team</a>, SEI, PKU</p>
|
<p> <a href='http://docklet.unias.org'>Docklet Team</a>, SEI, PKU</p>
|
||||||
''' % (env.getenv("PORTAL_URL"), env.getenv("PORTAL_URL"))
|
''' % (env.getenv("PORTAL_URL"), env.getenv("PORTAL_URL"))
|
||||||
text += '<p>'+ str(datetime.utcnow()) + '</p>'
|
text += '<p>'+ str(datetime.now()) + '</p>'
|
||||||
text += '</html>'
|
text += '</html>'
|
||||||
subject = 'Docklet account activated'
|
subject = 'Docklet account activated'
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
|
@ -107,7 +107,7 @@ def send_remind_activating_email(username):
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<p> Docklet Team, SEI, PKU</p>
|
<p> Docklet Team, SEI, PKU</p>
|
||||||
''' % (username, env.getenv("PORTAL_URL"), env.getenv("PORTAL_URL"))
|
''' % (username, env.getenv("PORTAL_URL"), env.getenv("PORTAL_URL"))
|
||||||
text += '<p>'+ str(datetime.utcnow()) + '</p>'
|
text += '<p>'+ str(datetime.now()) + '</p>'
|
||||||
text += '</html>'
|
text += '</html>'
|
||||||
subject = 'An activating request in Docklet has been sent'
|
subject = 'An activating request in Docklet has been sent'
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
|
@ -324,14 +324,14 @@ class userManager:
|
||||||
|
|
||||||
def set_nfs_quota_bygroup(self,groupname, quota):
|
def set_nfs_quota_bygroup(self,groupname, quota):
|
||||||
if not data_quota == "True":
|
if not data_quota == "True":
|
||||||
return
|
return
|
||||||
users = User.query.filter_by(user_group = groupname).all()
|
users = User.query.filter_by(user_group = groupname).all()
|
||||||
for user in users:
|
for user in users:
|
||||||
self.set_nfs_quota(user.username, quota)
|
self.set_nfs_quota(user.username, quota)
|
||||||
|
|
||||||
def set_nfs_quota(self, username, quota):
|
def set_nfs_quota(self, username, quota):
|
||||||
if not data_quota == "True":
|
if not data_quota == "True":
|
||||||
return
|
return
|
||||||
nfspath = "/users/%s/data" % username
|
nfspath = "/users/%s/data" % username
|
||||||
try:
|
try:
|
||||||
cmd = data_quota_cmd % (nfspath,quota+"GB")
|
cmd = data_quota_cmd % (nfspath,quota+"GB")
|
||||||
|
@ -769,6 +769,13 @@ class userManager:
|
||||||
will send an e-mail when status is changed from 'applying' to 'normal'
|
will send an e-mail when status is changed from 'applying' to 'normal'
|
||||||
Usage: modify(newValue = dict_from_form, cur_user = token_from_auth)
|
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()
|
user_modify = User.query.filter_by(username = kwargs['newValue'].get('username', None)).first()
|
||||||
if (user_modify == None):
|
if (user_modify == None):
|
||||||
|
|
||||||
|
@ -786,11 +793,12 @@ class userManager:
|
||||||
if (user_modify.status == 'applying' and form.get('status', '') == 'normal'):
|
if (user_modify.status == 'applying' and form.get('status', '') == 'normal'):
|
||||||
send_activated_email(user_modify.e_mail, user_modify.username)
|
send_activated_email(user_modify.e_mail, user_modify.username)
|
||||||
user_modify.status = form.get('status', '')
|
user_modify.status = form.get('status', '')
|
||||||
if (form.get('password', '') != ''):
|
#if (form.get('password', '') != ''):
|
||||||
new_password = form.get('password','')
|
#new_password = form.get('password','')
|
||||||
new_password = hashlib.sha512(new_password.encode('utf-8')).hexdigest()
|
#new_password = hashlib.sha512(new_password.encode('utf-8')).hexdigest()
|
||||||
user_modify.password = new_password
|
#user_modify.password = new_password
|
||||||
#self.chpassword(cur_user = user_modify, password = form.get('password','no_password'))
|
#self.chpassword(cur_user = user_modify, password = form.get('password','no_password'))
|
||||||
|
#modify password in another function now
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
res = self.groupQuery(name=user_modify.user_group)
|
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">
|
<input type = "text" placeholder="Enter Telephone Number" class="form-control" name="tel" id="mTel">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<!--div class="form-group">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<input type="password" placeholder="Enter Password" class="form-control" name="password" id="mPassword">
|
<input type="password" placeholder="Enter Password" class="form-control" name="password" id="mPassword">
|
||||||
</div>
|
</div-->
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>User Group</label>
|
<label>User Group</label>
|
||||||
|
@ -194,7 +194,12 @@
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{
|
{
|
||||||
"render": function ( data, type, row ) {
|
"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
|
"targets": 8
|
||||||
},
|
},
|
||||||
|
@ -249,5 +254,15 @@
|
||||||
$("#mDescription").val(result.description);
|
$("#mDescription").val(result.description);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function setActivateUser(arg){
|
||||||
|
$.post("/user/change/",
|
||||||
|
{
|
||||||
|
ID: arg,
|
||||||
|
Instruction: "Activate",
|
||||||
|
},
|
||||||
|
function(data,status){
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -327,6 +327,11 @@ def useradd():
|
||||||
def usermodify():
|
def usermodify():
|
||||||
return usermodifyView.as_view()
|
return usermodifyView.as_view()
|
||||||
|
|
||||||
|
@app.route("/user/change/", methods=['POST'])
|
||||||
|
@administration_required
|
||||||
|
def userchange():
|
||||||
|
return usermodifyView.as_view()
|
||||||
|
|
||||||
@app.route("/quota/add/", methods=['POST'])
|
@app.route("/quota/add/", methods=['POST'])
|
||||||
@administration_required
|
@administration_required
|
||||||
def quotaadd():
|
def quotaadd():
|
||||||
|
@ -545,4 +550,4 @@ if __name__ == '__main__':
|
||||||
elif opt in ("-p", "--port"):
|
elif opt in ("-p", "--port"):
|
||||||
webport = int(arg)
|
webport = int(arg)
|
||||||
|
|
||||||
app.run(host = webip, port = webport, threaded=True)
|
app.run(host = webip, port = webport, threaded=True,)
|
||||||
|
|
Loading…
Reference in New Issue