diff --git a/club/views.py b/club/views.py index 4d66b266..d47fa215 100644 --- a/club/views.py +++ b/club/views.py @@ -623,7 +623,6 @@ class PosterCreateView(PosterCreateBaseView, CanCreateMixin): pk_url_kwarg = "club_id" def get_object(self): - print(self.club) obj = super(PosterCreateView, self).get_object() if not obj: return self.club diff --git a/com/templates/com/poster_list.jinja b/com/templates/com/poster_list.jinja index 654c2a51..7bd340fd 100644 --- a/com/templates/com/poster_list.jinja +++ b/com/templates/com/poster_list.jinja @@ -32,7 +32,7 @@ {% else %} {% for poster in poster_list %} -
+
{{ poster.name }}
@@ -44,6 +44,13 @@ {% elif app == "club" %} {% trans %}Edit{% endtrans %} {% endif %} +
+
    + {% for screen in poster.screens.all() %} +
  • {{ screen }}
  • + {% endfor %} +
+
{% endfor %} diff --git a/com/templates/com/poster_moderate.jinja b/com/templates/com/poster_moderate.jinja index e6336854..d9b34082 100644 --- a/com/templates/com/poster_moderate.jinja +++ b/com/templates/com/poster_moderate.jinja @@ -22,7 +22,7 @@ {% else %} {% for poster in object_list %} -
+
{{ poster.name }}
Moderate diff --git a/com/views.py b/com/views.py index 93057717..dc8c1384 100644 --- a/com/views.py +++ b/com/views.py @@ -540,7 +540,6 @@ class PosterCreateBaseView(CreateView): def dispatch(self, request, *args, **kwargs): if 'club_id' in kwargs: self.club = get_object_or_404(Club, pk=kwargs['club_id']) - print(self.club) return super(PosterCreateBaseView, self).dispatch(request, *args, **kwargs) def get_form_kwargs(self): @@ -590,7 +589,7 @@ class PosterEditBaseView(UpdateView): return kwargs def form_valid(self, form): - if 'club' in self.__dict__ and self.club: + if self.request.user.is_com_admin: form.instance.is_moderated = False return super(PosterEditBaseView, self).form_valid(form) diff --git a/core/static/com/js/poster_create.js b/core/static/com/js/poster_create.js deleted file mode 100644 index 5438a2d4..00000000 --- a/core/static/com/js/poster_create.js +++ /dev/null @@ -1,22 +0,0 @@ -$(document).ready(function(){ - - $("#poster_list #view").click(function(e){ - $("#view").removeClass("active"); - }); - - $("#poster_list .poster").click(function(e){ - - el = $(e.target); - $("#poster_list #view #placeholder").html(el); - - $("#view").addClass("active"); - }); - - $(document).keyup(function(e) { - if (e.keyCode == 27) { // escape key maps to keycode `27` - e.preventDefault(); - $("#view").removeClass("active"); - } - }); - -}); diff --git a/core/static/core/style.scss b/core/static/core/style.scss index 8e28ea22..183fea3a 100644 --- a/core/static/core/style.scss +++ b/core/static/core/style.scss @@ -645,283 +645,194 @@ header { /*---------------------------POSTERS----------------------------*/ #poster_list, #screen_list, #poster_edit, #screen_edit{ - position: relative; - #title{ - position: relative; - padding: 10px; margin: 10px; - border-bottom: 2px solid black; - h3{ - display: flex; justify-content: center; align-items: center; - } - #links{ - position: absolute; display: flex; - bottom: 5px; - &.left{ left: 0; } - &.right{ right: 0; } - .link{ - padding: 5px; padding-left: 20px; padding-right: 20px; - margin-left: 5px; - border-radius: 20px; - background-color: #ffaa00; - color: black; - &:hover{ - color: black; - background-color: #c99836; - } - &.delete{ - background-color: #cb0000; - } - } - } - - } - #posters, #screens{ - position: relative; - display: flex; flex-wrap: wrap; - #no-posters, #no-screens{ - display: flex; justify-content: center; align-items: center; - } - .poster, .screen{ - min-width: 10%; max-width: 20%; - display: flex; flex-direction: column; - margin: 10px; border: 2px solid darkgrey; border-radius: 4px; - padding: 10px; - - background-color: lightgrey; - *{ - display: flex; justify-content: center; align-items: center; - } - .name{ - padding-bottom: 5px; margin-bottom: 5px; border-bottom: 1px solid whitesmoke; - } - .image{ - flex-grow: 1; - position: relative; - padding-bottom: 5px; margin-bottom: 5px; border-bottom: 1px solid whitesmoke; - img{ - max-height: 20vw; max-width: 100%; - } - &:hover{ - &::before{ - position: absolute; width: 100%; height: 100%; - display: flex; justify-content: center; align-items: center; flex-wrap: wrap; - top: 0; left: 0; z-index: 10; - content: "Click to expand"; - color: white; background-color: rgba(black, 0.5); - } - } - } - .dates{ - padding-bottom: 5px; margin-bottom: 5px; border-bottom: 1px solid whitesmoke; - *{ - display: flex; justify-content: center; align-items: center; flex-wrap: wrap; - margin-left: 5px; margin-right: 5px; - } - .begin, .end{ - width: 48%; - } - .begin{ - border-right: 1px solid whitesmoke; - padding-right: 2%; - } - } - .edit, .moderate, .slideshow{ - padding: 5px; - border-radius: 20px; - background-color: #ffaa00; - color: black; - &:hover{ - color: black; - background-color: #c99836; - } - &:nth-child(2n){ - margin-top: 5px; margin-bottom: 5px; - } - } - + .tooltip{ + visibility: hidden; + width: 120px; + background-color: #f9fafb; + color: #000; + text-align: center; + padding: 5px 0; + border-radius: 6px; + position: absolute; + z-index: 10; + ul{ + margin-left: 0; + display: inline-block; + li{ + display: list-item; + list-style-type: none; + } + } + } + &.not_moderated + { + border: 1px solid red; + } + &:hover .tooltip{ + visibility: visible; + } } - } - #view{ - position: fixed; - width: 100vw; height: 100vh; - display: flex; justify-content: center; align-items: center; - top: 0; left: 0; z-index: 10; - visibility: hidden; background-color: rgba(10, 10, 10, 0.9); - overflow: hidden; - &.active{ - visibility: visible; - } - #placeholder{ - width: 80vw; height: 80vh; - display: flex; justify-content: center; align-items: center; - top: 0; left: 0; - img{ - max-width: 100%; max-height: 100%; - } - } - } - } diff --git a/core/views/forms.py b/core/views/forms.py index 352e003f..c1f64a9c 100644 --- a/core/views/forms.py +++ b/core/views/forms.py @@ -2,8 +2,7 @@ # # Copyright 2016,2017 # - Skia -# - Sli -# +# - Sli # # Ce fichier fait partie du site de l'Association des Étudiants de l'UTBM, # http://ae.utbm.fr. # @@ -33,16 +32,17 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext from phonenumber_field.widgets import PhoneNumberInternationalFallbackWidget from ajax_select.fields import AutoCompleteSelectField +from ajax_select import make_ajax_field import re from core.models import User, Page, SithFile, Gift -from com.models import Poster, Screen from core.utils import resize_image from io import BytesIO from PIL import Image + # Widgets class SelectSingle(Select): @@ -261,10 +261,8 @@ class PagePropForm(forms.ModelForm): class Meta: model = Page fields = ['parent', 'name', 'owner_group', 'edit_groups', 'view_groups', ] - widgets = { - 'edit_groups': CheckboxSelectMultiple, - 'view_groups': CheckboxSelectMultiple, - } + edit_groups = make_ajax_field(Page, 'edit_groups', 'groups', help_text="", label=_("edit groups")) + view_groups = make_ajax_field(Page, 'view_groups', 'groups', help_text="", label=_("view groups")) def __init__(self, *arg, **kwargs): super(PagePropForm, self).__init__(*arg, **kwargs) @@ -276,10 +274,8 @@ class PageForm(forms.ModelForm): class Meta: model = Page fields = ['parent', 'name', 'owner_group', 'edit_groups', 'view_groups'] - widgets = { - 'edit_groups': CheckboxSelectMultiple, - 'view_groups': CheckboxSelectMultiple, - } + edit_groups = make_ajax_field(Page, 'edit_groups', 'groups', help_text="", label=_("edit groups")) + view_groups = make_ajax_field(Page, 'view_groups', 'groups', help_text="", label=_("view groups")) def __init__(self, *args, **kwargs): super(PageForm, self).__init__(*args, **kwargs)