Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passe à django 2.1 #5233

Merged
merged 12 commits into from Mar 7, 2019
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ sudo: required


python:
- 3.4
- 3.5


addons:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Expand Up @@ -12,3 +12,4 @@ sphinx_rtd_theme==0.2.4
faker==0.8.12
mock==2.0.0
colorlog==3.1.2
django-extensions==2.1.4
16 changes: 8 additions & 8 deletions requirements.txt
@@ -1,11 +1,11 @@
# Implicit dependencies (optional dependencies of dependencies)
python-social-auth==0.2.21
social-auth-app-django==3.1.0
elasticsearch==5.5.2
elasticsearch-dsl==5.4.0
sqlparse==0.2.4

# Explicit dependencies (references in code)
Django==1.11.15
Django==2.1.5
django-crispy-forms==1.7.2
django-model-utils==3.1.2
django-munin==0.2.1
Expand All @@ -20,15 +20,15 @@ beautifulsoup4==4.6.0
django-recaptcha==1.3.1
google-api-python-client==1.7.4
toml==0.10.0
requests==2.19.1
requests==2.21.0

# Api dependencies
djangorestframework==3.6.4
djangorestframework-xml==1.3.0
django-filter==1.1.0
djangorestframework==3.9.0
djangorestframework-xml==1.4.0
django-filter==2.0.0
django-oauth-toolkit==1.0.0
drf-extensions==0.3.1
django-rest-swagger==2.1.2
drf-extensions==0.4.0
django-rest-swagger==2.2.0
django-cors-middleware==1.3.1
dry-rest-permissions==0.1.10
oauth2client==4.1.3
Expand Down
12 changes: 7 additions & 5 deletions templates/forum/includes/topic_item.part.html
Expand Up @@ -46,11 +46,13 @@ <h3 class="content-title" itemprop="itemListElement">
{% if topic.tags.all %}
<ul class="content-tags" itemprop="keywords">
{% for tag in topic.tags.all|slice:":3" %}
<li>
<a href="{% url 'topic-tag-find' tag.slug %}" title="Tag {{ tag.title }}">
{{ tag.title }}
</a>
</li>
{% if tag.slug %}
<li>
<a href="{% url 'topic-tag-find' tag.slug %}" title="Tag {{ tag.title }}">
{{ tag.title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
Expand Down
12 changes: 7 additions & 5 deletions templates/forum/includes/topic_row.part.html
Expand Up @@ -30,11 +30,13 @@
{% if topic.tags.all %}
<ul class="topic-tags">
{% for tag in topic.tags.all %}
<li>
<a href="{% url 'topic-tag-find' tag.slug %}" class="topic-tag" title="Tag {{ tag.title }}">
{{ tag.title }}
</a>
</li>
{% if tag.slug %}
<li>
<a href="{% url 'topic-tag-find' tag.slug %}" class="topic-tag" title="Tag {{ tag.title }}">
{{ tag.title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
Expand Down
2 changes: 2 additions & 0 deletions templates/forum/topic/index.html
Expand Up @@ -51,11 +51,13 @@
{% if topic.tags.all %}
<ul class="taglist" itemprop="keywords">
{% for tag in topic.tags.all %}
{% if tag.slug %}
<li>
<a href="{% url 'topic-tag-find' tag.slug %}" rel="tag">
{{ tag.title }}
</a>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
Expand Down
4 changes: 3 additions & 1 deletion templates/header.html
Expand Up @@ -188,7 +188,9 @@
{% trans "Tags les plus utilisés" %}
</li>
{% for tag in top.tags %}
<li><a href="{{ tag.get_absolute_url }}">{{ tag.title }}</a></li>
{% if tag.slug %}
<li><a href="{{ tag.get_absolute_url }}">{{ tag.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
</li>
Expand Down
24 changes: 15 additions & 9 deletions zds/api/urls.py
@@ -1,17 +1,23 @@
from django.conf.urls import url, include
from django.urls import re_path, include

from rest_framework_swagger.views import get_swagger_view


schema_view = get_swagger_view()

urlpatterns = [
url(r'^$', schema_view, name='docs'),
url(r'^contenus/', include('zds.tutorialv2.api.urls', namespace='content')),
url(r'^forums/', include('zds.forum.api.urls', namespace='forum')),
url(r'^galeries/', include('zds.gallery.api.urls', namespace='gallery')),
url(r'^membres/', include('zds.member.api.urls', namespace='member')),
url(r'^mps/', include('zds.mp.api.urls', namespace='mp')),
url(r'^tags/', include('zds.utils.api.urls', namespace='tag')),
url(r'^notifications/', include('zds.notification.api.urls', namespace='notification')),
re_path(r'^$', schema_view, name='docs'),
re_path(r'^contenus/', include(('zds.tutorialv2.api.urls',
'zds.tutorialv2.api'), namespace='content')),
re_path(r'^forums/', include(('zds.forum.api.urls',
'zds.forum.api'), namespace='forum')),
re_path(r'^galeries/', include(('zds.gallery.api.urls',
'zds.gallery.api'), namespace='gallery')),
re_path(r'^membres/', include(('zds.member.api.urls',
'zds.member.api'), namespace='member')),
re_path(r'^mps/', include(('zds.mp.api.urls', 'zds.mp.api'), namespace='mp')),
re_path(r'^tags/', include(('zds.utils.api.urls',
'zds.utils.api'), namespace='tag')),
re_path(r'^notifications/', include(('zds.notification.api.urls',
'zds.notification.api'), namespace='notification')),
]
2 changes: 1 addition & 1 deletion zds/featured/forms.py
Expand Up @@ -2,7 +2,7 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Field, ButtonHolder
from django import forms
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _

from zds.featured.models import FeaturedResource, FeaturedMessage
Expand Down
2 changes: 1 addition & 1 deletion zds/featured/tests.py
@@ -1,5 +1,5 @@
from datetime import datetime, date
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import TestCase
from django.utils.translation import ugettext as _

Expand Down
20 changes: 13 additions & 7 deletions zds/featured/urls.py
@@ -1,13 +1,19 @@
from django.conf.urls import url
from django.urls import re_path

from zds.featured.views import FeaturedResourceList, FeaturedResourceCreate, FeaturedResourceUpdate, \
FeaturedResourceDeleteDetail, FeaturedResourceDeleteList, FeaturedMessageCreateUpdate

urlpatterns = [
url(r'^$', FeaturedResourceList.as_view(), name='featured-resource-list'),
url(r'^unes/creer/$', FeaturedResourceCreate.as_view(), name='featured-resource-create'),
url(r'^unes/editer/(?P<pk>\d+)/$', FeaturedResourceUpdate.as_view(), name='featured-resource-update'),
url(r'^unes/supprimer/(?P<pk>\d+)/$', FeaturedResourceDeleteDetail.as_view(), name='featured-resource-delete'),
url(r'^unes/supprimer/$', FeaturedResourceDeleteList.as_view(), name='featured-resource-list-delete'),
url(r'^message/modifier/$', FeaturedMessageCreateUpdate.as_view(), name='featured-message-create'),
re_path(r'^$', FeaturedResourceList.as_view(),
name='featured-resource-list'),
re_path(r'^unes/creer/$', FeaturedResourceCreate.as_view(),
name='featured-resource-create'),
re_path(r'^unes/editer/(?P<pk>\d+)/$',
FeaturedResourceUpdate.as_view(), name='featured-resource-update'),
re_path(r'^unes/supprimer/(?P<pk>\d+)/$',
FeaturedResourceDeleteDetail.as_view(), name='featured-resource-delete'),
re_path(r'^unes/supprimer/$', FeaturedResourceDeleteList.as_view(),
name='featured-resource-list-delete'),
re_path(r'^message/modifier/$', FeaturedMessageCreateUpdate.as_view(),
name='featured-message-create'),
]
2 changes: 1 addition & 1 deletion zds/featured/views.py
Expand Up @@ -2,7 +2,7 @@

from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db import transaction
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
Expand Down
2 changes: 1 addition & 1 deletion zds/forum/api/tests.py
@@ -1,6 +1,6 @@
from django.conf import settings
from django.core.cache import caches
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.models import Group
from rest_framework import status
from rest_framework.test import APIClient
Expand Down
7 changes: 4 additions & 3 deletions zds/forum/api/urls.py
@@ -1,7 +1,8 @@
from django.conf.urls import url
from django.urls import re_path

from .views import PostKarmaView
from zds.forum.api.views import PostKarmaView

urlpatterns = [
url(r'^message/(?P<pk>\d+)/karma/?$', PostKarmaView.as_view(), name='post-karma'),
re_path(r'^message/(?P<pk>\d+)/karma/?$',
PostKarmaView.as_view(), name='post-karma'),
]
2 changes: 1 addition & 1 deletion zds/forum/forms.py
@@ -1,6 +1,6 @@
from django import forms
from django.conf import settings
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _

from crispy_forms.helper import FormHelper
Expand Down
4 changes: 2 additions & 2 deletions zds/forum/managers.py
Expand Up @@ -46,7 +46,7 @@ def visibility_check_query(self, current_user):
:param current_user:
:return:
"""
if current_user.is_authenticated():
if current_user.is_authenticated:
return Q(forum__groups__isnull=True) | Q(forum__groups__pk__in=current_user.profile.group_pks)
else:
return Q(forum__groups__isnull=True)
Expand Down Expand Up @@ -110,7 +110,7 @@ def visibility_check_query(self, current_user):
:param current_user:
:return:
"""
if current_user.is_authenticated():
if current_user.is_authenticated:
return Q(topic__forum__groups__isnull=True) | Q(topic__forum__groups__pk__in=current_user.profile.group_pks)
return Q(topic__forum__groups__isnull=True)

Expand Down
22 changes: 11 additions & 11 deletions zds/forum/migrations/0001_initial.py
Expand Up @@ -35,7 +35,7 @@ class Migration(migrations.Migration):
('image', models.ImageField(upload_to='forum/normal')),
('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')),
('category', models.ForeignKey(verbose_name=b'Cat\xc3\xa9gorie', to='forum.Category', on_delete=models.CASCADE)),
('group', models.ManyToManyField(to='auth.Group', null=True, verbose_name=b'Groupe autoris\xc3\xa9s (Aucun = public)', blank=True)),
],
options={
Expand All @@ -47,7 +47,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Post',
fields=[
('comment_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='utils.Comment')),
('comment_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='utils.Comment', on_delete=models.CASCADE)),
('is_useful', models.BooleanField(default=False, verbose_name=b'Est utile')),
],
options={
Expand All @@ -65,9 +65,9 @@ class Migration(migrations.Migration):
('is_locked', models.BooleanField(default=False, verbose_name=b'Est verrouill\xc3\xa9')),
('is_sticky', models.BooleanField(default=False, db_index=True, verbose_name=b'Est en post-it')),
('key', models.IntegerField(null=True, verbose_name=b'cle', blank=True)),
('author', models.ForeignKey(related_name='topics', verbose_name=b'Auteur', to=settings.AUTH_USER_MODEL)),
('forum', models.ForeignKey(verbose_name=b'Forum', to='forum.Forum')),
('last_message', models.ForeignKey(related_name='last_message', verbose_name=b'Dernier message', to='forum.Post', null=True)),
('author', models.ForeignKey(related_name='topics', verbose_name=b'Auteur', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
('forum', models.ForeignKey(verbose_name=b'Forum', to='forum.Forum', on_delete=models.CASCADE)),
('last_message', models.ForeignKey(related_name='last_message', verbose_name=b'Dernier message', to='forum.Post', null=True, on_delete=models.CASCADE)),
('tags', models.ManyToManyField(db_index=True, to='utils.Tag', null=True, verbose_name=b'Tags du forum', blank=True)),
],
options={
Expand All @@ -81,8 +81,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('email', models.BooleanField(default=False, db_index=True, verbose_name=b'Notification par courriel')),
('topic', models.ForeignKey(to='forum.Topic')),
('user', models.ForeignKey(related_name='topics_followed', to=settings.AUTH_USER_MODEL)),
('topic', models.ForeignKey(to='forum.Topic', on_delete=models.CASCADE)),
('user', models.ForeignKey(related_name='topics_followed', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Sujet suivi',
Expand All @@ -94,9 +94,9 @@ class Migration(migrations.Migration):
name='TopicRead',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('post', models.ForeignKey(to='forum.Post')),
('topic', models.ForeignKey(to='forum.Topic')),
('user', models.ForeignKey(related_name='topics_read', to=settings.AUTH_USER_MODEL)),
('post', models.ForeignKey(to='forum.Post', on_delete=models.CASCADE)),
('topic', models.ForeignKey(to='forum.Topic', on_delete=models.CASCADE)),
('user', models.ForeignKey(related_name='topics_read', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],
options={
'verbose_name': 'Sujet lu',
Expand All @@ -107,7 +107,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='post',
name='topic',
field=models.ForeignKey(verbose_name=b'Sujet', to='forum.Topic'),
field=models.ForeignKey(verbose_name=b'Sujet', to='forum.Topic', on_delete=models.CASCADE),
preserve_default=True,
),
]
25 changes: 25 additions & 0 deletions zds/forum/migrations/0017_auto_20190114_1301.py
@@ -0,0 +1,25 @@
# Generated by Django 2.1.5 on 2019-01-14 13:01

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('forum', '0016_topic_solved_by'),
]

operations = [
migrations.AlterField(
model_name='topic',
name='last_message',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='last_message', to='forum.Post', verbose_name='Dernier message'),
),
migrations.AlterField(
model_name='topic',
name='solved_by',
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Utilisateur ayant noté le sujet comme résolu'),
),
]