Affichage sommaire des avis
This commit is contained in:
parent
e151fc3d1e
commit
3e9d26eef0
3 changed files with 51 additions and 11 deletions
|
@ -175,7 +175,7 @@ class AvisStage(models.Model):
|
|||
stage = models.OneToOneField(Stage, related_name="avis_stage")
|
||||
|
||||
chapo = models.TextField(u"En quelques mots", blank=True)
|
||||
avis_personnes = RichTextField(u"Les encadrants et l'équipe", blank=True)
|
||||
avis_ambiance = RichTextField(u"L'ambiance de travail", blank=True)
|
||||
avis_sujet = RichTextField(u"Le sujet de stage", blank=True)
|
||||
avis_admin = RichTextField(u"Formalités et administration", blank=True)
|
||||
|
||||
|
@ -183,7 +183,13 @@ class AvisStage(models.Model):
|
|||
les_moins = models.TextField(u"Les moins du stage", blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"Avis sur {%s} par %" % (stage.sujet, stage.auteur.user.username)
|
||||
return u"Avis sur {%s} par %s" % (self.stage.sujet, self.stage.auteur.user.username)
|
||||
|
||||
@property
|
||||
def avis_all(self):
|
||||
fields = ['avis_ambiance', 'avis_sujet', 'avis_admin']
|
||||
return [(AvisStage._meta.get_field(field).verbose_name,
|
||||
getattr(self, field, '')) for field in fields]
|
||||
|
||||
class AvisLieu(models.Model):
|
||||
stage = models.ForeignKey(Stage)
|
||||
|
@ -206,3 +212,8 @@ class AvisLieu(models.Model):
|
|||
def __unicode__(self):
|
||||
return u"Avis sur {%s} par %s" % (self.lieu.nom, self.stage.auteur.user_id)
|
||||
|
||||
@property
|
||||
def avis_all(self):
|
||||
fields = ['avis_lieustage', 'avis_pratique', 'avis_tourisme']
|
||||
return [(AvisLieu._meta.get_field(field).verbose_name,
|
||||
getattr(self, field, '')) for field in fields]
|
||||
|
|
33
avisstage/templates/avisstage/detail/avis.html
Normal file
33
avisstage/templates/avisstage/detail/avis.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
<section class="avis">
|
||||
<h1>{{ titre }}</h1>
|
||||
{% if avis.chapo %}
|
||||
<p class="chapo">
|
||||
{{ avis.chapo }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% for av in avis.avis_all %}
|
||||
{% if av.1 %}
|
||||
<div class="avis_item">
|
||||
<h2>{{ av.0 }}</h2>
|
||||
<div class="avis_texte">
|
||||
{{ av.1|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div class="plusmoins">
|
||||
{% if avis.les_plus %}
|
||||
<div class="plus">
|
||||
<h3>Super si vous aimez...</h3>
|
||||
<p>{{ avis.les_plus }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if avis.les_moins %}
|
||||
<div class="moins">
|
||||
<h3>Pas génial pour...</h3>
|
||||
<p>{{ avis.les_moins }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
|
@ -20,14 +20,10 @@
|
|||
</ul>
|
||||
</section>
|
||||
|
||||
{% with object.avis_stage as avis %}
|
||||
<section class="avis">
|
||||
{% if avis.chapo %}
|
||||
<p class="chapo">
|
||||
{{ avis.chapo }}
|
||||
</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endwith %}
|
||||
{% include "avisstage/detail/avis.html" with avis=object.avis_stage titre="Avis sur le stage" %}
|
||||
|
||||
{% for avis in object.avislieu_set.all %}
|
||||
{% include "avisstage/detail/avis.html" with avis=avis titre="Avis sur le lieu" %}
|
||||
{% endfor %}
|
||||
</article>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue