Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/zestedesavoir/zds-site into …
Browse files Browse the repository at this point in the history
…zep-13-b
  • Loading branch information
gustavi committed Oct 31, 2016
2 parents 293d6db + df1933e commit 0a67e3d
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 69 deletions.
Binary file added assets/images/home-clem-halloween.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions assets/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
this.modals.abbr = new window.Modal({
"title": this.titles.abbr,
"body": "<div>" +
"<label for=zform-modal-abbr-abbr>Abbréviation :</label>" +
"<label for=zform-modal-abbr-abbr>Abréviation :</label>" +
"<input type=text id=zform-modal-abbr-abbr />" +
"</div><div>" +
"<label for=zform-modal-abbr-text>Texte :</label>" +
Expand Down Expand Up @@ -622,8 +622,6 @@
document.getElementById("zform-modal-abbr-abbr").value = "";
document.getElementById("zform-modal-abbr-abbr").focus();
}

return true;
}
break;

Expand Down
4 changes: 4 additions & 0 deletions assets/scss/base/_high-pixel-ratio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
body.vc-clem-christmas.home .home-search-box::before {
background-image: url('../images/[email protected]');
}

body.vc-clem-halloween.home .home-search-box::before {
background-image: url('../images/[email protected]');
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion assets/scss/pages/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,13 @@ $content-width: 1145px;

@at-root {
body.vc-clem-christmas.home .home-search-box::before {
background-image: url('../images/[email protected]');
background-image: url('../images/home-clem-christmas.png');
}

body.vc-clem-halloween.home .home-search-box::before {
background-image: url('../images/home-clem-halloween.png');
width: 160px;
left: -80px;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion doc/source/install/configs/settings_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@

# visual changes
#ZDS_APP['visual_changes'] = ['snow', 'clem-christmas']

ZDS_APP['visual_changes'] = ['clem-halloween']
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pygments==2.1.3
python-social-auth==0.2.19

# Explicit dependencies (references in code)
Django==1.8.14
Django==1.8.15
django-crispy-forms==1.6.0
django-haystack==2.4.1
django-model-utils==2.5
Expand Down
12 changes: 3 additions & 9 deletions templates/gallery/gallery/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</button>

<div class="gallery topic-list list-view clearfix navigable-list">
{% for img in gallery.get_images %}
{% for img in images %}
<div class="topic gallery-item navigable-elem">
<div class="topic-infos">
<input name="items" type="checkbox" value="{{ img.pk }}">
Expand All @@ -91,14 +91,6 @@

<a href="{% url "gallery-image-new" gallery.pk %}" title="Ajouter une image" class="gallery-item add-image">+</a>
</div>

{% if gallery_mode.can_write %}
<button class="btn btn-cancel" name="delete_multi" tabindex="-1">{% trans "Supprimer la sélection" %}</button>
{% endif %}

<button class="toggle-gallery-view btn btn-grey" type="button" tabindex="-1">
{% trans "Vue grille" %}
</button>
{% else %}
<p>
{% trans "Aucune image" %}. <br>
Expand All @@ -111,6 +103,8 @@
{% endif %}
</p>
{% endif %}

{% include "misc/paginator.html" with position="bottom" %}
</form>
{% endblock %}

Expand Down
5 changes: 5 additions & 0 deletions update.md
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,11 @@ Utilisateur `zds`:
+ "-V mainfont=Merriweather -V monofont=\"SourceCodePro-Regular\" "
```
Actions à faire pour activer le thème d'Halloween
=================================================

Ajouter `ZDS_APP['visual_changes'] = ['clem-halloween']` à `settings_prod.py`.

---

**Notes auxquelles penser lors de l'édition de ce fichier (à laisser en bas) :**
Expand Down
1 change: 0 additions & 1 deletion zds/forum/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=80, verbose_name=b'Titre')),
('subtitle', models.CharField(max_length=200, verbose_name=b'Sous-titre')),
('image', models.ImageField(upload_to=zds.forum.models.image_path_forum)),
('position_in_category', models.IntegerField(db_index=True, null=True, verbose_name=b'Position dans la cat\xc3\xa9gorie', blank=True)),
('slug', models.SlugField(unique=True, max_length=80)),
('category', models.ForeignKey(verbose_name=b'Cat\xc3\xa9gorie', to='forum.Category')),
Expand Down
37 changes: 2 additions & 35 deletions zds/forum/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# coding: utf-8

import os
import string
import uuid
import logging
from datetime import datetime, timedelta
from math import ceil
Expand All @@ -26,19 +23,6 @@ def sub_tag(tag):
return u"{0}".format(start + end)


def image_path_forum(instance, filename):
"""
Return path to an image.
TODO: what is the usage of this function?
:param instance:
:param filename:
:return:
"""
ext = filename.split('.')[-1]
filename = u'{}.{}'.format(str(uuid.uuid4()), string.lower(ext))
return os.path.join('forum/normal', str(instance.pk), filename)


class Category(models.Model):
"""
A Category is a simple container for Forums.
Expand Down Expand Up @@ -101,8 +85,6 @@ class Meta:
Group,
verbose_name='Groupe autorisés (Aucun = public)',
blank=True)
# TODO: A forum defines an image, but it doesn't seems to be used...
image = models.ImageField(upload_to=image_path_forum)

category = models.ForeignKey(Category, db_index=True, verbose_name='Catégorie')
position_in_category = models.IntegerField('Position dans la catégorie',
Expand Down Expand Up @@ -303,7 +285,7 @@ def resolve_last_read_post_absolute_url(self):
"""
user = get_current_user()
if user is None or not user.is_authenticated():
return self.resolve_first_post_url()
return self.first_unread_post().get_absolute_url()
else:
try:
pk, pos = self.resolve_last_post_pk_and_pos_read_by_user(user)
Expand All @@ -313,7 +295,7 @@ def resolve_last_read_post_absolute_url(self):
return '{}?page={}#p{}'.format(
self.get_absolute_url(), page_nb, pk)
except TopicRead.DoesNotExist:
return self.resolve_first_post_url()
return self.first_unread_post().get_absolute_url()

def resolve_last_post_pk_and_pos_read_by_user(self, user):
"""get the primary key and position of the last post the user read
Expand All @@ -335,20 +317,6 @@ def resolve_last_post_pk_and_pos_read_by_user(self, user):
.order_by('position')\
.values('pk', "position").first().values()

def resolve_first_post_url(self):
"""resolve the url that leads to this topic first post
:return: the url
"""
pk = Post.objects\
.filter(topic__pk=self.pk)\
.order_by('position')\
.values('pk').first()

return '{0}?page=1#p{1}'.format(
self.get_absolute_url(),
pk['pk'])

def first_unread_post(self, user=None):
"""
Returns the first post of this topics the current user has never read, or the first post if it has never read \
Expand All @@ -357,7 +325,6 @@ def first_unread_post(self, user=None):
:return: The first unread post for this topic and this user.
"""
# TODO: Why 2 nearly-identical functions? What is the functional need of these 2 things?
try:
if user is None:
user = get_current_user()
Expand Down
24 changes: 14 additions & 10 deletions zds/gallery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import os
from django.utils.translation import ugettext_lazy as _

from django.views.generic import DetailView, CreateView, UpdateView, DeleteView, FormView
from django.views.generic import CreateView, UpdateView, DeleteView, FormView
from django.utils.decorators import method_decorator
from zds.tutorialv2.models.models_database import PublishableContent

Expand Down Expand Up @@ -125,25 +125,29 @@ def ensure_user_access(gallery, user, can_write=False):
return user_gallery


class GalleryDetails(DetailView):
class GalleryDetails(ZdSPagingListView):
"""Gallery details"""

model = Gallery
object = UserGallery
template_name = "gallery/gallery/details.html"
context_object_name = "gallery"
context_object_name = "images"
paginate_by = settings.ZDS_APP['gallery']['images_per_page']

@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(GalleryDetails, self).dispatch(*args, **kwargs)

def get_queryset(self):
self.pkey = self.kwargs.pop('pk', None)
self.slug = self.kwargs.pop('slug', None)
self.gallery = get_object_or_404(Gallery, pk=self.pkey, slug=self.slug)
self.user_access = ensure_user_access(self.gallery, self.request.user, can_write=True)
return self.gallery.get_images().order_by('title')

def get_context_data(self, **kwargs):
context = super(GalleryDetails, self).get_context_data(**kwargs)

context['gallery_mode'] = ensure_user_access(self.object, self.request.user)
context['images'] = self.object.get_images()
context['gallery_mode'] = self.user_access
context['form'] = UserGalleryForm
context['content_linked'] = PublishableContent.objects.filter(gallery__pk=self.object.pk).first()

context['gallery'] = self.gallery
return context


Expand Down
1 change: 1 addition & 0 deletions zds/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
'gallery': {
'image_max_size': 1024 * 1024,
'gallery_per_page': 21,
'images_per_page': 21,
},
'article': {
'home_number': 3,
Expand Down
9 changes: 1 addition & 8 deletions zds/utils/templatetags/tests/tests_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from django.test import TestCase
from django.template import Context, Template
from django.utils import timezone


class DateFormatterTest(TestCase):
Expand Down Expand Up @@ -109,10 +108,4 @@ def test_humane_time(self):
"{{ date_epoch | humane_time }}"
).render(self.context)

# Since ZdS is in Europe/Paris, hours can be 0 or 1
paris = timezone.pytz.timezone('Europe/Paris')
is_dst = paris.localize(datetime.now()).dst() == timedelta(0, 3600)

hour = 1 if is_dst else 0

self.assertEqual(tr, u"jeudi 01 janvier 1970 à 0{}h00".format(hour))
self.assertEqual(tr, u"jeudi 01 janvier 1970 à 01h00")

0 comments on commit 0a67e3d

Please sign in to comment.