Adding the core applications code to the repository
This commit is contained in:
0
notes/__init__.py
Normal file
0
notes/__init__.py
Normal file
BIN
notes/__pycache__/__init__.cpython-35.pyc
Normal file
BIN
notes/__pycache__/__init__.cpython-35.pyc
Normal file
Binary file not shown.
BIN
notes/__pycache__/admin.cpython-35.pyc
Normal file
BIN
notes/__pycache__/admin.cpython-35.pyc
Normal file
Binary file not shown.
BIN
notes/__pycache__/forms.cpython-35.pyc
Normal file
BIN
notes/__pycache__/forms.cpython-35.pyc
Normal file
Binary file not shown.
BIN
notes/__pycache__/models.cpython-35.pyc
Normal file
BIN
notes/__pycache__/models.cpython-35.pyc
Normal file
Binary file not shown.
10
notes/admin.py
Normal file
10
notes/admin.py
Normal 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
5
notes/apps.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class NotesConfig(AppConfig):
|
||||
name = 'notes'
|
||||
20
notes/forms.py
Normal file
20
notes/forms.py
Normal 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)
|
||||
23
notes/migrations/0001_initial.py
Normal file
23
notes/migrations/0001_initial.py
Normal 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()),
|
||||
],
|
||||
),
|
||||
]
|
||||
30
notes/migrations/0002_auto_20160804_1221.py
Normal file
30
notes/migrations/0002_auto_20160804_1221.py
Normal 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'),
|
||||
),
|
||||
]
|
||||
0
notes/migrations/__init__.py
Normal file
0
notes/migrations/__init__.py
Normal file
BIN
notes/migrations/__pycache__/0001_initial.cpython-35.pyc
Normal file
BIN
notes/migrations/__pycache__/0001_initial.cpython-35.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
notes/migrations/__pycache__/__init__.cpython-35.pyc
Normal file
BIN
notes/migrations/__pycache__/__init__.cpython-35.pyc
Normal file
Binary file not shown.
39
notes/models.py
Normal file
39
notes/models.py
Normal 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
3
notes/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
Reference in New Issue
Block a user