small fixes on comment page calculation + added functionality to clear unread notification from button in user home + quick css fixes
authordurandn
Fri, 05 Aug 2016 10:01:50 +0200
changeset 100 8ec8aced3f68
parent 99 21ed0482625b
child 101 eb856f9b518c
small fixes on comment page calculation + added functionality to clear unread notification from button in user home + quick css fixes
src/iconolab/models.py
src/iconolab/static/iconolab/css/iconolab.css
src/iconolab/templates/iconolab/user_home.html
src/iconolab/views/iconolab.py
--- a/src/iconolab/models.py	Thu Aug 04 15:36:32 2016 +0200
+++ b/src/iconolab/models.py	Fri Aug 05 10:01:50 2016 +0200
@@ -378,11 +378,9 @@
     
     # Get page for considered comment, with COMMENTS_PER_PAGE_DEFAULT comments per page
     def get_comment_page(self):
-        return self._default_manager.filter(
-            object_pk=self.object_pk, 
-            content_type__app_label=self.content_type.app_label, 
-            content_type__model=self.content_type.model
-        ).order_by("thread_id", "-order").filter(thread_id__lt=self.thread_id, order__gt=self.order).count() // settings.COMMENTS_PER_PAGE_DEFAULT + 1
+        return (self._default_manager.for_app_models("iconolab.annotation").filter(
+            object_pk=self.object_pk,
+        ).filter(thread_id__gte=self.thread_id).filter(order__lte=self.order).count()) // settings.COMMENTS_PER_PAGE_DEFAULT + 1
     
 class MetaCategory(models.Model):
     NONE = 0 # Notifies nobody
--- a/src/iconolab/static/iconolab/css/iconolab.css	Thu Aug 04 15:36:32 2016 +0200
+++ b/src/iconolab/static/iconolab/css/iconolab.css	Fri Aug 05 10:01:50 2016 +0200
@@ -73,33 +73,18 @@
 .badge-error {
   background-color: #b94a48;
 }
-.badge-error:hover {
-  background-color: #953b39;
-}
 .badge-warning {
   background-color: #f89406;
 }
-.badge-warning:hover {
-  background-color: #c67605;
-}
 .badge-success {
   background-color: #468847;
 }
-.badge-success:hover {
-  background-color: #356635;
-}
 .badge-info {
   background-color: #3a87ad;
 }
-.badge-info:hover {
-  background-color: #2d6987;
-}
 .badge-inverse {
   background-color: #333333;
 }
-.badge-inverse:hover {
-  background-color: #1a1a1a;
-}
 
 .notif-badge{
   margin-bottom: 5px;
--- a/src/iconolab/templates/iconolab/user_home.html	Thu Aug 04 15:36:32 2016 +0200
+++ b/src/iconolab/templates/iconolab/user_home.html	Fri Aug 05 10:01:50 2016 +0200
@@ -18,7 +18,7 @@
         {% notifications_unread as unread_count %}
         <h4><span class="badge notif-badge {% if unread_count %}badge-error{% endif %}">{{unread_count}}</span> Notifications non lues 
           <a href="{% url 'user_notifications' %}" class="btn btn-default btn-xs">Voir toutes mes notifications</a>
-          <a href=# class="btn btn-default btn-xs">Tout marquer comme lu</a>
+          <a href="{% url 'user_home' profile_user.id %}?clear_notifications=True" class="btn btn-default btn-xs">Tout marquer comme lu</a>
         </h4>
         <div class="row">
           <div class="col-md-12">
@@ -54,10 +54,13 @@
           <div class="col-md-6">
             <h4>{% if profile_user == request.user %}Mes annotations:{% else %}Annotations de {{profile_user.username}}{% endif %} </h4>
             <ul class="list-inline">
+            {% if not user_annotations %}
+              Aucune annotation à afficher
+            {% endif %}
             {% for annotation in user_annotations.all %}
             <li>
               <div class="panel panel-default" style="min-width: 375px;">
-                  <div class="panel-heading">Title</div>
+                  <div class="panel-heading">{{annotation.current_revision.title}}</div>
                   <div class="fragment-container" style="position:relative; display:inline-block">
                     {% thumbnail annotation.image.media "150x150" crop=False as im %}
                       <a href="{% url 'annotation_detail' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid %}">
--- a/src/iconolab/views/iconolab.py	Thu Aug 04 15:36:32 2016 +0200
+++ b/src/iconolab/views/iconolab.py	Fri Aug 05 10:01:50 2016 +0200
@@ -53,6 +53,8 @@
         comments_annotations_id = [int(str_id) for str_id in comments_annotations_str_id]
         context["user_comments_annotations"] = Annotation.objects.filter(id__in=comments_annotations_id).exclude(author=profile_user).distinct()
         if request.user.is_authenticated() and self.object == request.user:
+            if request.GET.get("clear_notifications", False):
+                Notification.objects.filter(recipient=request.user).mark_all_as_read()
             context["notifications"] = Notification.objects.filter(recipient=request.user)
         return render(request, 'iconolab/user_home.html', context)