repair 'Observation' forms

This commit is contained in:
Arthur Gerbaud
2016-08-06 20:21:59 +02:00
parent e593981696
commit 73696a5b7b
5 changed files with 14 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ class Observation(Note):
def __str__(self):
return "%s" % self.sujet
def note_date(self):
""" Enforce value of created_date """
return self.rencontre.date

View File

@@ -6,9 +6,9 @@
<span class="pull-right"><a href="{% url 'maraudes:liste' %}" class="btn btn-primary btn-sm">Aller à la liste</a></span></p>
</div>
<div class="list-group">
{% for maraude in dernieres_maraudes %}
<a href="{% url 'maraudes:details' maraude.pk %}" class="list-group-item">
<strong>{{ maraude }}</strong> <small>{{maraude.binome}} & {{maraude.referent}}</small>
{% for m in dernieres_maraudes %}
<a href="{% url 'maraudes:details' m.pk %}" class="list-group-item {% if maraude == m %} active{% endif %}">
<strong>{{ m }}</strong> <small>{{m.binome}} & {{m.referent}}</small>
</a>
{% endfor %}
</div>

View File

@@ -93,7 +93,10 @@ class MaraudeListView(MaraudesView, generic.ListView):
class CompteRenduCreateView(MaraudesView, generic.DetailView):
model = Maraude
template_name = "compte_rendu/compterendu_create.html"
context_object_name = "maraude"
header = "Compte-rendu"
header_small = "maraude"
form = None
inline_formset = None

View File

@@ -32,14 +32,17 @@ class Note(models.Model):
created_time = models.TimeField('Heure', blank=True, null=True)
def save(self, *args, **kwargs):
child_instance = self.cast()
self.created_date = child_instance.note_date()
self.created_time = child_instance.note_time()
if not self.created_date or not self.created_time:
child_instance = self.cast()
self.created_date = child_instance.note_date()
self.created_time = child_instance.note_time()
return super().save(*args, **kwargs)
def _get_child_class_and_instance(self):
self._child_instance = self
self._child_class = self.__class__
if self._meta.get_parent_list(): # If self is actually child instance
return
for f in self._meta.get_fields():
if f.is_relation and f.one_to_one:
self._child_instance = getattr(self, f.name)

View File

@@ -16,7 +16,7 @@
<tr><td colspan="2">{{ sujet.parcours_de_vie }}</td><th>Lien familial</th><td>{{ sujet.lien_familial }}</td></tr>
</table>
<div class="panel-footer text-right">
<a href="{% url "sujets:update" pk=sujet.id %}" class="btn btn-primary">Mettre à jour</a>
<a href="{% url "sujets:update" pk=sujet.id %}" class="btn btn-sm btn-default">Mettre à jour</a>
</div>
</div>