Adding the core applications code to the repository

This commit is contained in:
artus
2016-08-05 10:41:43 +02:00
parent 243ff9153e
commit 5f4faf46ec
155 changed files with 13176 additions and 0 deletions

0
notes/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

10
notes/admin.py Normal file
View File

@@ -0,0 +1,10 @@
from django.contrib import admin
from .models import *
# Register your models here.
@admin.register(Note)
class NoteAdmin(admin.ModelAdmin):
list_display = ['id', 'sujet']
list_filter = ('sujet',)

5
notes/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class NotesConfig(AppConfig):
name = 'notes'

20
notes/forms.py Normal file
View File

@@ -0,0 +1,20 @@
from .models import Note
from django import forms
from django_select2.forms import Select2Widget
from django.forms import Textarea
class NoteForm(forms.ModelForm):
class Meta:
model = Note
fields = ['sujet', 'text']
widgets = {
'sujet': Select2Widget(),
'text': Textarea(attrs={'rows':4}),
}
def save(self, *args, **kwargs):
# Get data for extra fields of Note
return super().save(*args, **kwargs)

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-04 10:21
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Note',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField()),
],
),
]

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-04 10:21
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('notes', '0001_initial'),
('utilisateurs', '0001_initial'),
('sujets', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='note',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='utilisateurs.Professionnel'),
),
migrations.AddField(
model_name='note',
name='sujet',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notes', to='sujets.Sujet'),
),
]

View File

Binary file not shown.

39
notes/models.py Normal file
View File

@@ -0,0 +1,39 @@
from django.db import models
class Note(models.Model):
""" Note relative à un sujet.
"""
sujet = models.ForeignKey(
'sujets.Sujet',
related_name="notes",
on_delete=models.CASCADE
)
text = models.TextField()
created_by = models.ForeignKey(
'utilisateurs.Professionnel',
blank=True,
null=True
)
#date_created = models.DateField('Crée le')
def as_table(self):
pass
def get_header(self):
""" Informations included in headers """
return ('Note', [])
def get_date(self):
raise NotImplementedError
def header_label(self):
return self.get_header()[0]
def header_infos(self):
return self.get_header()[1]
@property
def date(self):
return self.get_date()

3
notes/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.