1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 07:22:34 +00:00

wip: udpate profile page

This commit is contained in:
zhengxie
2018-11-24 11:08:19 +08:00
parent f423f62b8e
commit 139459de01
2 changed files with 47 additions and 0 deletions

View File

@@ -79,6 +79,18 @@
</div>
{% endif %}
{% if ENABLE_WEBDAV_SECRET %}
<div id="update-webdav-passwd" class="setting-item">
<h3>WebDav {% trans "Password" %}</h3>
<label>{% trans "Password" %}</label><input type="text" name="password" value="{{ webdav_passwd }}" class="input" />
<br/>
<a href="#" class="update sf-btn-link">{% trans "Update" %}</a>
<a href="#" class="delete sf-btn-link">{% trans "Delete" %}</a>
</div>
{% endif %}
{% if ENABLE_ADDRESSBOOK_OPT_IN %}
<div class="setting-item" id="list-in-address-book">
<h3>{% trans "Global Address Book" %}</h3>
@@ -233,6 +245,33 @@ $("#list-in-address-book input[type='checkbox']").on('change', function() {
});
{% endif %}
{% if ENABLE_WEBDAV_SECRET %}
function aj_update_webdav_secret(passwd) {
$.ajax({
url: "{% url 'api-v2.1-webdav-secret' %}",
type: 'PUT',
dataType: 'json',
cache: false,
beforeSend: prepareCSRFToken,
data: "secret=" + passwd,
success: function(data) {
feedback("{% trans "Success" %}", 'success');
},
error: ajaxErrorHandler
});
}
$("#update-webdav-passwd a.update").click(function() {
var passwd = $("#update-webdav-passwd input[type='text']").val();
aj_update_webdav_secret(passwd);
});
$("#update-webdav-passwd a.delete").click(function() {
$("#update-webdav-passwd input[type='text']").val('');
aj_update_webdav_secret('');
});
{% endif %}
(function() {
var lang_context = $('#lang-context'),
lang_selector = $('#lang-context-selector');

View File

@@ -75,6 +75,12 @@ def edit_profile(request):
owned_repos = get_owned_repo_list(request)
owned_repos = filter(lambda r: not r.is_virtual, owned_repos)
if settings.ENABLE_WEBDAV_SECRET:
decoded = UserOptions.objects.get_webdav_decoded_secret(username)
webdav_passwd = decoded if decoded else ''
else:
webdav_passwd = ''
resp_dict = {
'form': form,
'server_crypto': server_crypto,
@@ -86,6 +92,8 @@ def edit_profile(request):
'is_ldap_user': is_ldap_user(request.user),
'two_factor_auth_enabled': has_two_factor_auth(),
'ENABLE_CHANGE_PASSWORD': settings.ENABLE_CHANGE_PASSWORD,
'ENABLE_WEBDAV_SECRET': settings.ENABLE_WEBDAV_SECRET,
'webdav_passwd': webdav_passwd,
}
if has_two_factor_auth():