Some changes for profile

This commit is contained in:
Patrick Jentsch
2022-12-19 15:35:06 +01:00
parent c0d015acd8
commit c00f5230a1
4 changed files with 60 additions and 66 deletions

View File

@ -68,8 +68,8 @@
<div class="row">
<div class="col s2"></div>
<div class="col s8">
{% if current_user.avatar %}
<img src="{{ url_for('profile.avatar_download', user_id=user.id, avatar_id=current_user.avatar.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
{% if user.avatar %}
<img src="{{ url_for('.profile_avatar', user_id=user.id) }}" alt="user-image" class="circle responsive-img" id="avatar">
{% else %}
<img src="{{ url_for('static', filename='images/user_avatar.png') }}" alt="user-image" class="circle responsive-img" id="placeholder-avatar">
{% endif %}
@ -83,7 +83,7 @@
</div>
</div>
<div class="col s10">
{{wtf.render_field(edit_public_profile_information_form.avatar, accept='image/jpeg, image/png, image/gif', placeholder='Choose an image file', id='avatar-upload', data_action='disable')}}
{{ wtf.render_field(edit_public_profile_information_form.avatar, accept='image/jpeg, image/png, image/gif', placeholder='Choose an image file', id='avatar-upload', data_action='disable') }}
</div>
</div>
</div>
@ -165,15 +165,14 @@ avatarUpload.addEventListener('change', function() {
deleteButton.addEventListener('click', function() {
return new Promise((resolve, reject) => {
let user_id = "{{ current_user.hashid }}";
let avatar_id = "{{ current_user.avatar.hashid }}";
let user_id = {{ user.hashid }};
fetch(`/profile/${user_id}/avatars/${avatar_id}`, {method: 'DELETE', headers: {Accept: 'application/json'}})
fetch(`/profile/${user_id}/avatar`, {method: 'DELETE', headers: {Accept: 'application/json'}})
.then(
(response) => {
if (response.status === 403) {app.flash('Forbidden', 'error'); reject(response);}
if (response.status === 404) {app.flash('Not Found', 'error'); reject(response);}
app.flash(`Avatar marked for deletion`, 'corpus');
app.flash('Avatar marked for deletion');
resolve(response);
},
(response) => {

View File

@ -13,7 +13,7 @@
<br>
<br>
{% if user.avatar %}
<img src="{{ url_for('profile.avatar_download', user_id=user.id, avatar_id=user.avatar.id) }}" alt="user-image" class="circle responsive-img">
<img src="/profile/{{ user.id }}/avatar" alt="user-image" class="circle responsive-img">
{% else %}
<img src="{{ url_for('static', filename='images/user_avatar.png') }}" alt="user-image" class="circle responsive-img">
{% endif %}
@ -25,15 +25,15 @@
<h3 style="float:left">{{ user.username }}<span class="new badge green" id="public-information-badge" data-badge-caption="custom caption" style="margin-top:20px;"></span></h3>
</div>
<div class="col 12">
{% if user_data['show_last_seen'] %}
<div class="chip">Last seen: {{ user.last_seen.strftime('%Y-%m-%d %H:%M') }}</div>
{% if user.show_last_seen %}
<div class="chip">Last seen: {{ user.last_seen }}</div>
{% endif %}
{% if user.location %}
<p><span class="material-icons" style="margin-right:20px; margin-top:20px;">location_on</span><i>{{ user.location }}</i></p>
{% endif %}
<p></p>
<br>
{% if user.about_me%}
{% if user.about_me %}
<div style="border-left: solid 3px #E91E63; padding-left: 15px;">
<h5>About me</h5>
<p>{{ user.about_me }}</p>
@ -57,7 +57,7 @@
<td>{{ user.full_name }} </td>
</tr>
{% endif %}
{% if user_data['show_email'] %}
{% if user.show_email %}
<tr>
<td><span class="material-icons">email</span></td>
<td>{{ user.email }}</td>
@ -77,13 +77,13 @@
{% endif %}
</table>
<br>
{% if user_data['show_member_since'] %}
<p><i>Member since: {{ user.member_since.strftime('%Y-%m-%d') }}</i></p>
{% if user.show_member_since %}
<p><i>Member since: {{ user.member_since }}</i></p>
{% endif %}
<p></p>
<br>
{% if current_user.is_authenticated and current_user.id == user.id %}
<a class="waves-effect waves-light btn-small" href="{{ url_for('profile.edit_profile', user_id=user.id) }}">Edit profile</a>
<a class="waves-effect waves-light btn-small" href="{{ url_for('.edit_profile', user_id=user.id) }}">Edit profile</a>
{% endif %}
</div>
</div>