Skip to content

Commit

Permalink
For #26 🐛 menu UI add unsibscribe link; fix dj msg on success
Browse files Browse the repository at this point in the history
  • Loading branch information
lissa3 committed Oct 25, 2023
1 parent f1d77ad commit 932cbda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/profiles/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import messages
from django.contrib.auth import logout
from django.contrib.auth.mixins import LoginRequiredMixin as LRM
from django.http import JsonResponse
Expand All @@ -20,6 +21,7 @@ def get(self, request, **kwargs):
return render(request, "profiles/profile_detail.html", ctx)

def post(self, request, **kwargs):
# js reload page: trigger dj msg
uuid = kwargs.get("uuid")
profile = get_object_or_404(Profile, uuid=uuid)
form = ProfileForm(request.POST, request.FILES, profile)
Expand All @@ -30,6 +32,7 @@ def post(self, request, **kwargs):
else:
profile.avatar = None
profile.save()
messages.success(request, "Avatar changed successfully")
return JsonResponse({"status_code": 200, "resp": "OK"})
else:
return JsonResponse({"status_code": 404, "err": form.errors})
Expand Down
5 changes: 0 additions & 5 deletions src/static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ function fileToDataUri(file) {
});
}

// const colorSVG = (colorCls)=>{
// let circle = document.getElementById("avaColor")
// circle.classList.add(colorCls);
// }




7 changes: 7 additions & 0 deletions src/templates/components/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
{% trans 'Subscribe to news' %}
</a>
</li>
{% else %}
<li><hr class="dropdown-divider"></li>
<li class="nav-item">
<a class="dropdown-item" href="{% url 'contacts:end_news' user.profile.uuid %}" >
{% trans 'Usubscribe to news' %}
</a>
</li>
{% endif %}
</ul>
</li>
Expand Down

0 comments on commit 932cbda

Please sign in to comment.