diff --git a/scipost/models.py b/scipost/models.py index 70043eb9ef6182e21059823cb86cc4094a652a34..b11f9dfa18664594e8bf0fdc8af714a637d5c876 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -304,7 +304,7 @@ class List(models.Model): def contents(self): context = Context({}) - output = self.description + output = '<p>' + self.description + '</p>' output += '<hr class="hr6"/>' emptylist = True if self.submissions.exists(): diff --git a/scipost/templates/scipost/list.html b/scipost/templates/scipost/list.html index 61a2d56fafbf5b37bd013107957e3ed6416282d0..64ce0dcf0fc10b4530f3a93443facb7e83cb7761 100644 --- a/scipost/templates/scipost/list.html +++ b/scipost/templates/scipost/list.html @@ -12,14 +12,14 @@ <section> <h1>List detail</h1> - {{ list.header }} - <hr class="hr6"/> <br/> - {{ list.contents }} {% load guardian_tags %} {% get_obj_perms request.user for list as "list_perms" %} + + {% include 'scipost/list_contents.html' %} + {% if "change_list" in list_perms %} <hr class="hr6"/> diff --git a/scipost/templates/scipost/list_contents.html b/scipost/templates/scipost/list_contents.html new file mode 100644 index 0000000000000000000000000000000000000000..b508f95cd8b48faa60223c4ed661a59b2811e53d --- /dev/null +++ b/scipost/templates/scipost/list_contents.html @@ -0,0 +1,85 @@ + +{% if not "change_list" in list_perms %} + +{{ list.contents }} + +{% else %} + +<p>Description: +<p>{{ list.description }}</p> +</p> + + +<hr class="hr6"/> + +{% if list.submissions.exists or list.commentaries.exists or list.thesislinks.exists or list.comments.exists %} + +{% if list.submissions.exists %} +<p>Submissions: + <ul> + {% for sub in list.submissions.all %} + {{ sub.simple_header_as_li }} + {% if "change_list" in list_perms %} + <form action="{% url 'scipost:list_remove_element' list_id=list.id type='S' element_id=sub.id %}" method="post"> + {% csrf_token %} + <input type="submit" value="Remove from List"/> + </form> + {% endif %} + {% endfor %} + </ul> +</p> +{% endif %} + +{% if list.commentaries.exists %} +<p>Commentaries: + <ul> + {% for com in list.commentaries.all %} + {{ com.simple_header_as_li }} + {% if "change_list" in list_perms %} + <form action="{% url 'scipost:list_remove_element' list_id=list.id type='C' element_id=com.id %}" method="post"> + {% csrf_token %} + <input type="submit" value="Remove from List"/> + </form> + {% endif %} + {% endfor %} + </ul> +</p> +{% endif %} + +{% if list.thesislinks.exists %} +<p>Thesis links: + <ul> + {% for tl in list.thesislinks.all %} + {{ tl.simple_header_as_li }} + {% if "change_list" in list_perms %} + <form action="{% url 'scipost:list_remove_element' list_id=list.id type='T' element_id=tl.id %}" method="post"> + {% csrf_token %} + <input type="submit" value="Remove from List"/> + </form> + {% endif %} + {% endfor %} + </ul> +</p> +{% endif %} + +{% if list.comments.exists %} +<p>Comments: + <ul> + {% for comment in list.comments.all %} + {{ comment.simple_header_as_li }} + {% if "change_list" in list_perms %} + <form action="{% url 'scipost:list_remove_element' list_id=list.id type='c' element_id=comment.id %}" method="post"> + {% csrf_token %} + <input type="submit" value="Remove from List"/> + </form> + {% endif %} + {% endfor %} + </ul> +</p> +{% endif %} + +{% else %} +<br/><h3>This List is empty.</h3> +{% endif %} + +{% endif %} diff --git a/scipost/templates/scipost/quick_tour.html b/scipost/templates/scipost/quick_tour.html index 495aee0d782fdc9ba4d9701a04c0b62bae2ed150..5ed6ad75bc1c5e042bf2677e82fe221c7338852d 100644 --- a/scipost/templates/scipost/quick_tour.html +++ b/scipost/templates/scipost/quick_tour.html @@ -6,9 +6,6 @@ {% block bodysup %} -<!-- Temporary strip for online version --> -{% if user.is_authenticated %} - <section> <div class="flex-greybox"> @@ -48,7 +45,4 @@ </section> - -{% endif %} <!-- temporary strip --> - {% endblock bodysup %} diff --git a/scipost/urls.py b/scipost/urls.py index 768db3895622968f67d0dbc179fdb34527a0d2e9..9a64dc3c5dc44d41426fa694ba00b16731e7d9e9 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -64,6 +64,7 @@ urlpatterns = [ url(r'^create_list$', views.create_list, name='create_list'), url(r'^list/(?P<list_id>[0-9]+)$', views.list, name='list'), url(r'^list_add_element/(?P<list_id>[0-9]+)/(?P<type>[SCTc])/(?P<element_id>[0-9]+)$', views.list_add_element, name='list_add_element'), + url(r'^list_remove_element/(?P<list_id>[0-9]+)/(?P<type>[SCTc])/(?P<element_id>[0-9]+)$', views.list_remove_element, name='list_remove_element'), # Feeds url(r'^latest_comment/feed/$', LatestCommentFeed()), diff --git a/scipost/views.py b/scipost/views.py index a9291fae598ad5abf5002d90709ac486eccf36b4..33d687c15b9a8bd1fd03c1e99fe61c1137d8b185 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -767,6 +767,24 @@ def list_add_element(request, list_id, type, element_id): return redirect(reverse('scipost:list', kwargs={'list_id': list_id})) +@permission_required_or_403('scipost.change_list', (List, 'id', 'list_id')) +def list_remove_element(request, list_id, type, element_id): + list = get_object_or_404(List, pk=list_id) + if type == 'C': + commentary = get_object_or_404(Commentary, pk=element_id) + list.commentaries.remove(commentary) + elif type == 'S': + submission = get_object_or_404(Submission, pk=element_id) + list.submissions.remove(submission) + elif type == 'T': + thesislink = get_object_or_404(ThesisLink, pk=element_id) + list.thesislinks.remove(thesislink) + elif type == 'c': + comment = get_object_or_404(Comment, pk=element_id) + list.comments.remove(comment) + return redirect(reverse('scipost:list', kwargs={'list_id': list_id})) + + ######### # Teams # #########