Skip to content

Commit

Permalink
Passage à Django 1.8 minimal (il reste plein de warnings mais ça marche)
Browse files Browse the repository at this point in the history
Impacts directs obligatoires :
- Une relation en base change de nom pour être python-compatible (et donc sa migration en base)
- On doit maintenant préciser le paramètre --fake-initial lors d'une migration de MAJ (cf https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---fake-initial)
- Debug Toolbar en v1.3
- Fix pour que oauth fonctionne, cf jazzband/django-oauth-toolkit#204
  • Loading branch information
SpaceFox authored and artragis committed Nov 11, 2015
1 parent bf6401b commit 3ce4012
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Tous les détails sur le workflow se trouvent [sur la page dédiée](http://zds-
| Nouvelle Fonctionnalité ? | [oui|non]
| Tickets (_issues_) concernés | [Liste de tickets séparés par des virgules]
```
* Ajoutez des notes de QA (Quality Assurance). Ces notes doivent permettent à un testeur de comprendre ce que vous avez modifié, ce qu'il faut tester en priorité et les pièges auxquels il doit s'attendre et donc sur lesquels porter une attention particulière. Précisez tout particulièrement s'il est nécessaire d'effectuer une action de gestion préalable, comme `python manage.py migrate`, `python manage.py loaddata fixture/*.yaml` ou `npm run gulp -- build`.
* Ajoutez des notes de QA (Quality Assurance). Ces notes doivent permettent à un testeur de comprendre ce que vous avez modifié, ce qu'il faut tester en priorité et les pièges auxquels il doit s'attendre et donc sur lesquels porter une attention particulière. Précisez tout particulièrement s'il est nécessaire d'effectuer une action de gestion préalable, comme `python manage.py migrate --fake-initial`, `python manage.py loaddata fixture/*.yaml` ou `npm run gulp -- build`.

## Les commits
* Pour les commits, nous suivons le même ordre d'idée des standards Git, à savoir :
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Après avoir mis à jour votre dépôt, vous devez exécuter les commandes suiva

```console
pip install --upgrade -r requirements.txt -r requirements-dev.txt
python manage.py migrate
python manage.py migrate --fake-initial
```


Expand Down
2 changes: 1 addition & 1 deletion doc/source/back-end-code/arborescence-back.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Cela permettra aux autres développeurs de répercuter les modifications en util

.. sourcecode:: bash

python manage.py migrate
python manage.py migrate --fake-initial


API
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ PyYAML==3.11
django-debug-toolbar==1.3.0
flake8==2.4.0
autopep8==1.1.1
sphinx==1.3.1
sphinx_rtd_theme==0.1.8
sphinx==1.2.3
sphinx_rtd_theme==0.1.6
fake-factory==0.5.0
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pygments==2.0.2
python-social-auth==0.2.9

# Explicit dependencies (references in code)
django==1.7.10
django==1.8.0
coverage==4.0.1
django-crispy-forms==1.4.0
django-haystack==2.3.1
Expand All @@ -31,5 +31,5 @@ drf-extensions==0.2.7
django-rest-swagger==0.2.9
django-cors-headers==1.0.0

# Zep 12 dependency
# Zep 12 dependency
django-uuslug==1.0.3
2 changes: 1 addition & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cd /opt/zdsenv/ZesteDeSavoir/
# Maintenance mode
sudo rm /etc/nginx/sites-enabled/zestedesavoir
sudo ln -s /etc/nginx/sites-available/zds-maintenance /etc/nginx/sites-enabled/zds-maintenance
sudo systemctl reload nginx.service
sudo service nginx reload

# Delete old branch if exists
git checkout prod
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3>{% trans "Système / Back-end" %}</h3>
<h4>{% trans "Site" %}</h4>
<ul>
<li><a href="http://www.python.org/">Python 2.7</a></li>
<li><a href="https://www.djangoproject.com/">Django 1.7</a></li>
<li><a href="https://www.djangoproject.com/">Django 1.8</a></li>
</ul>

<h4>HTTP(S) + WSGI</h4>
Expand Down
75 changes: 75 additions & 0 deletions zds/migrations/oauth2_provider/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import oauth2_provider.validators
import oauth2_provider.generators
from django.conf import settings


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='AccessToken',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('token', models.CharField(max_length=255, db_index=True)),
('expires', models.DateTimeField()),
('scope', models.TextField(blank=True)),
],
),
migrations.CreateModel(
name='Application',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('client_id', models.CharField(default=oauth2_provider.generators.generate_client_id, unique=True, max_length=100, db_index=True)),
('redirect_uris', models.TextField(help_text='Allowed URIs list, space separated', blank=True, validators=[oauth2_provider.validators.validate_uris])),
('client_type', models.CharField(max_length=32, choices=[('confidential', 'Confidential'), ('public', 'Public')])),
('authorization_grant_type', models.CharField(max_length=32, choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit'), ('password', 'Resource owner password-based'), ('client-credentials', 'Client credentials')])),
('client_secret', models.CharField(default=oauth2_provider.generators.generate_client_secret, max_length=255, db_index=True, blank=True)),
('name', models.CharField(max_length=255, blank=True)),
('skip_authorization', models.BooleanField(default=False)),
('user', models.ForeignKey(related_name='oauth2_provider_application', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Grant',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('code', models.CharField(max_length=255, db_index=True)),
('expires', models.DateTimeField()),
('redirect_uri', models.CharField(max_length=255)),
('scope', models.TextField(blank=True)),
('application', models.ForeignKey(to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='RefreshToken',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('token', models.CharField(max_length=255, db_index=True)),
('access_token', models.OneToOneField(related_name='refresh_token', to='oauth2_provider.AccessToken')),
('application', models.ForeignKey(to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='accesstoken',
name='application',
field=models.ForeignKey(to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL),
),
migrations.AddField(
model_name='accesstoken',
name='user',
field=models.ForeignKey(blank=True, to=settings.AUTH_USER_MODEL, null=True),
),
]
Empty file.
13 changes: 10 additions & 3 deletions zds/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@
'zds.gallery',
'zds.mp',
'zds.article',

'zds.forum',
'zds.tutorial',
'zds.tutorialv2',
Expand Down Expand Up @@ -360,6 +359,7 @@
# Fake mails (in console)
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

from django.contrib.messages import constants as message_constants
MESSAGE_TAGS = {
message_constants.DEBUG: 'debug',
message_constants.INFO: 'info',
Expand Down Expand Up @@ -539,10 +539,17 @@
# See http://daniel.hepper.net/blog/2014/04/fixing-1_6-w001-when-upgrading-from-django-1-5-to-1-7/
TEST_RUNNER = 'django.test.runner.DiscoverRunner'

# makemigrations requires this for some reason or it errors
# Just set to the default value
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'

# tell django where to put the oauth2 migrations
MIGRATION_MODULES = {
# key: app name, value: a fully qualified package name, not the usual `app_label.something_else`
'oauth2_provider': 'zds.migrations.oauth2_provider',
}
# Properly handle HTTPS vs HTTP
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# /!\ WARNING : It will probably open security holes in your site if the proxy behing isn't well configured
# Read the docs for further informations - https://docs.djangoproject.com/en/1.7/ref/settings/#secure-proxy-ssl-header

# Load the production settings, overwrite the existing ones if needed
try:
Expand Down
20 changes: 20 additions & 0 deletions zds/utils/migrations/0002_auto_20150414_2256.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

dependencies = [
('utils', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='comment',
name='editor',
field=models.ForeignKey(related_name='comments-editor+', verbose_name=b'Editeur', blank=True, to=settings.AUTH_USER_MODEL, null=True),
),
]
2 changes: 1 addition & 1 deletion zds/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Meta:
author = models.ForeignKey(User, verbose_name='Auteur',
related_name='comments', db_index=True)
editor = models.ForeignKey(User, verbose_name='Editeur',
related_name='comments-editor',
related_name='comments-editor+',
null=True, blank=True)
ip_address = models.CharField('Adresse IP de l\'auteur ', max_length=39)

Expand Down

0 comments on commit 3ce4012

Please sign in to comment.