This repository has been archived by the owner on May 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
89 additions
and
25 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Dossier | ||
|
||
admin.site.register(Dossier) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DossierConfig(AppConfig): | ||
name = 'dossier' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django import forms | ||
|
||
from .models import Dossier | ||
|
||
class DossierForm(forms.ModelForm): | ||
class Meta: | ||
model = Dossier | ||
fields = [ 'title', 'redacteurs', 'sommaire', 'articles' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.db import models | ||
from django.conf import settings | ||
|
||
class Dossier(models.Model): | ||
title = models.CharField(max_length=200, null=False, blank=False) | ||
redacteurs = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True) | ||
sommaire = models.ForeignKey('article.Article', null=True, blank=True, on_delete=models.SET_NULL) | ||
articles = models.ManyToManyField('article.Article', blank=True, related_name='dossiers', through='DossierOrder') | ||
|
||
class DossierOrder(models.Model): | ||
order = models.PositiveIntegerField() | ||
dossier = models.ForeignKey(Dossier, on_delete=models.CASCADE) | ||
article = models.ForeignKey('article.Article', on_delete=models.CASCADE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.conf.urls import url, include | ||
|
||
from .views import DossierList, DossierAdd, DossierDetail, DossierEdit | ||
|
||
app_name = 'dossier' | ||
|
||
dossier_patterns = [ | ||
url(r'^$', DossierList.as_view(), name='list'), | ||
url(r'^new$', DossierAdd.as_view(), name='add'), | ||
url(r'^(?P<pk>.+)/$', DossierDetail.as_view(), name='display'), | ||
url(r'^(?P<pk>.+)/edit$', DossierEdit.as_view(), name='edit'), | ||
] | ||
|
||
urlpatterns = [ | ||
url(r'^dossiers/', include(dossier_patterns)), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.shortcuts import render | ||
from django.views.generic import ListView, DetailView, CreateView, UpdateView | ||
|
||
from .models import Dossier | ||
from .forms import DossierForm | ||
|
||
from lxml import etree | ||
|
||
class DossierList(ListView): | ||
model = Dossier | ||
context_object_name = 'dossiers' | ||
template_name = 'list_page.html' | ||
|
||
class DossierDetail(DetailView): | ||
model = Dossier | ||
template_name = 'display.html' | ||
|
||
class DossierEdit(UpdateView): | ||
model = Dossier | ||
form_class = DossierForm | ||
template_name = 'edit.html' | ||
|
||
class DossierAdd(CreateView): | ||
model = Dossier | ||
form_class = DossierForm | ||
template_name = 'edit.html' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters