repairs 'notes' in master before branching
This commit is contained in:
@@ -18,10 +18,9 @@ class Observation(Note):
|
|||||||
verbose_name = "Observation"
|
verbose_name = "Observation"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "<Observation: %s>" % self.sujet
|
return "%s" % self.sujet
|
||||||
|
|
||||||
def get_date(self):
|
def save(self, *args, **kwargs):
|
||||||
return self.rencontre.date
|
if not self.created_date:
|
||||||
|
self.created_date = self.rencontre.date
|
||||||
def get_header(self):
|
return super().save(*args, **kwargs)
|
||||||
return ('Rencontre', [self.rencontre.lieu, "%smin" % self.rencontre.duree])
|
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ from .models import *
|
|||||||
@admin.register(Note)
|
@admin.register(Note)
|
||||||
class NoteAdmin(admin.ModelAdmin):
|
class NoteAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
list_display = ['id', 'sujet']
|
list_display = ['created_date', 'sujet']
|
||||||
list_filter = ('sujet',)
|
list_filter = ('sujet', 'created_date', 'created_by')
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.html import format_html
|
||||||
|
|
||||||
class Note(models.Model):
|
class Note(models.Model):
|
||||||
""" Note relative à un sujet.
|
""" Note relative à un sujet.
|
||||||
@@ -15,25 +16,51 @@ class Note(models.Model):
|
|||||||
blank=True,
|
blank=True,
|
||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
#date_created = models.DateField('Crée le')
|
created_date = models.DateField('Crée le', blank=True, null=True)
|
||||||
|
|
||||||
|
|
||||||
def as_table(self):
|
def as_table(self):
|
||||||
pass
|
html = format_html(
|
||||||
|
"<tr><th>{} <span class='label label-info'>{}</span>\
|
||||||
|
<span class='label label-info'>{}</span></th>\
|
||||||
|
\n<tr><td>{}</td></tr>",
|
||||||
|
self.sujet,
|
||||||
|
self.created_date,
|
||||||
|
self.created_by,
|
||||||
|
self.text
|
||||||
|
)
|
||||||
|
return html
|
||||||
|
|
||||||
def get_header(self):
|
def as_inline_table(self):
|
||||||
""" Informations included in headers """
|
html = format_html(
|
||||||
return ('Note', [])
|
"<tr><th class='bg-success'><strong>{}</strong> <small>{}</small> \n\
|
||||||
|
<span class='label label-info pull-right'>{}</span></th>\n\
|
||||||
|
<tr><td>{}</td></tr>",
|
||||||
|
self.subclass.__qualname__,
|
||||||
|
self.created_date,
|
||||||
|
self.created_by,
|
||||||
|
self.text
|
||||||
|
)
|
||||||
|
return html
|
||||||
|
|
||||||
def get_date(self):
|
def _get_child_and_subclass(self):
|
||||||
raise NotImplementedError
|
self._child_instance = None
|
||||||
|
self._subclass = None
|
||||||
def header_label(self):
|
for f in self._meta.get_fields():
|
||||||
return self.get_header()[0]
|
if f.is_relation and f.one_to_one:
|
||||||
|
self._child_instance = getattr(self, f.name)
|
||||||
def header_infos(self):
|
self._subclass = self._child_instance.__class__
|
||||||
return self.get_header()[1]
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def date(self):
|
def subclass(self):
|
||||||
return self.get_date()
|
if not hasattr(self, '_subclass'):
|
||||||
|
self._get_child_and_subclass()
|
||||||
|
return self._subclass
|
||||||
|
|
||||||
|
def cast(self):
|
||||||
|
if not hasattr(self, '_child_instance'):
|
||||||
|
self._get_child_and_subclass()
|
||||||
|
return self._child_instance
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "%s of %s" % (self.subclass.__qualname__, self.created_by)
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
<ul class="nav nav-pills nav-justified" role="tablist" style="padding-bottom:20px;float:bottom;">
|
|
||||||
<li role="presentation" class="active"><a href="#suivi" aria-controls="suivi" role="tab" data-toggle="tab">Suivi</a></li>
|
|
||||||
<li role="presentation"><a href="#fiche" aria-controls="fiche" role="tab" data-toggle="tab">Fiche</a></li>
|
|
||||||
</ul>
|
|
||||||
<!-- Tab panes -->
|
|
||||||
<div class="tab-content">
|
|
||||||
<div role="tabpanel" class="tab-pane active" id="suivi">{% include "suivis/sujet_suivi.html" %}</div>
|
|
||||||
<div role="tabpanel" class="tab-pane" id="fiche">{% include "sujets/sujet_details_inner.html" %}</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<div class="col-md-4">
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">Sujets</div>
|
|
||||||
<div class="list-group">
|
|
||||||
<a href="{% url 'sujets:liste' %}" class="list-group-item">Liste complète</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if user.is_superuser %}
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="panel panel-danger">
|
|
||||||
<div class="panel-heading">Administration</div>
|
|
||||||
<div class="list-group">
|
|
||||||
<a href="{% url 'sujets:create' %}" class="list-group-item">Nouveau sujet</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<div class="col-md-6">
|
|
||||||
<table class="table table-striped table-bordered">
|
|
||||||
{% for note in notes %}
|
|
||||||
<tr><th>{{note.date}}
|
|
||||||
<div class="pull-right">
|
|
||||||
<span class="label label-primary">{{ note.header_label }}</span>
|
|
||||||
{% for info in note.header_infos %}<span class="label label-info">{{ info }}</span>
|
|
||||||
{%endfor%}
|
|
||||||
</div>
|
|
||||||
</th></tr>
|
|
||||||
<tr><td>{{note.note}}</td></tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
@@ -17,16 +17,16 @@ class SuivisView(views.WebsiteProtectedMixin):
|
|||||||
|
|
||||||
|
|
||||||
class IndexView(SuivisView, generic.TemplateView):
|
class IndexView(SuivisView, generic.TemplateView):
|
||||||
template_name = "suivis/index.html"
|
template_name = "suivi/index.html"
|
||||||
header_small = "Tableau de bord"
|
header_small = "Tableau de bord"
|
||||||
|
|
||||||
|
|
||||||
class SuiviSujetView(SuivisView, generic.DetailView):
|
class SuiviSujetView(SuivisView, generic.DetailView):
|
||||||
model = Sujet
|
model = Sujet
|
||||||
template_name = "suivis/details.html"
|
template_name = "suivi/details.html"
|
||||||
context_object_name = "sujet"
|
context_object_name = "sujet"
|
||||||
|
|
||||||
def get_context_date(self, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(*args, **kwargs)
|
||||||
context['notes'] = self.object.notes.all()
|
context['notes'] = self.object.notes.all()
|
||||||
return context
|
return context
|
||||||
|
|||||||
Reference in New Issue
Block a user