Created
October 25, 2011 15:32
-
-
Save anonymous/1313146 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
material_detail.html | |
{% extends "base.html" %} | |
<body bgcolor="F7FBFA"> | |
<div id="content"> | |
{% block content %} | |
<body bgcolor="F7FBFA"> | |
{% if object.get_physical_properties %} | |
<ul> | |
<TT> <strong><font size="4" color="black">Materiau : </font></strong><font size="4" color="red"> <strong>{{ object }}</strong></font></TT> | |
{% for prop in object.get_physical_properties|slice:":1" %} | |
<TT> {{ prop.name.description|linebreaks }}</TT> | |
{% endfor %} | |
{% for prop in object.get_physical_properties %} | |
{% ifchanged prop.nature_unit %} {# test unique sur le changement de propriete avec la precedente #} | |
<thead> | |
<p style=background-color:PowderBlue;> <TT><font size="4" color="black"><strong> {{prop.nature_unit}} </strong></font></TT></p> | |
</thead> | |
{% for media in object.get_medias %} | |
{% ifequal prop.nature_unit media.nature %} {# test l'egalite sur la propriete #} | |
<a href="{{ media.source.url }}">{{ media.name }} {{ media.get_format_display }}</a> | |
{#<a href="{% url liendyn media.id %}">{{ media.name }} {{ media.get_format_display }}</a>#} | |
{% endifequal %} | |
{% endfor %} | |
<table width="100%" border="1" style="border: 0.5px;" cellspacing="0" cellpadding="0" > | |
<div> | |
<tr bgcolor="dddddd"> | |
<td width="150" <TT><strong>Propriete </strong></TT></td> | |
<td width="150" <TT><strong>Valeur min </strong></TT></td> | |
<td width="150" <TT><strong>Valeur max</strong></TT></td> | |
<td width="150" <TT><strong>Unite</strong></TT></td> | |
</tr> | |
<tr> | |
{% ifequal prop.val_champ 'durete Vickers' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> {# #} | |
<td width="150" <TT> <a href="{% url lit_param prop.id %}"> {{ prop.val1 }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val2 }} </TT> </td> | |
{% else %} | |
{% ifequal prop.val_champ 'module elasticite' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val1 }} </TT> </td> | |
<td width="150" <TT> {{ prop.val2 }} </TT> </td> | |
{% else %} | |
{% ifequal prop.val_champ 'masse volumique' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> | |
<td width="150" <TT> <a href="{% url lit_param2 prop.id %}"> {{ prop.val1 }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val2 }}</TT> </td> | |
{% else %} | |
{% ifequal prop.val_champ 'conductivite thermique' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> | |
<td width="150" <TT> <a href="{% url lit_param3 prop.id %}"> {{ prop.val1 }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val2 }}</TT> </td> | |
{% else %} | |
<td width="150" <TT>{{ prop.val_champ}} </TT></td> | |
<td width="150" <TT> {{ prop.val1 }}</TT> </td> | |
<td width="150" <TT> {{ prop.val2 }}</TT> </td> | |
{% endifequal %} | |
{% endifequal %} | |
{% endifequal %} | |
{% endifequal %} | |
<td width="150" <TT> {{ prop.val_unit }} </TT></td> | |
</tr> | |
</div> | |
</table> | |
{% else %} | |
<table width="100%" border="1" style="border: 0.5px;" cellspacing="0" cellpadding="0" > | |
<div> | |
<tr> | |
{% ifequal prop.val_champ 'durete Vickers' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> {# #} | |
<td width="150" <TT> <a href="{% url lit_param prop.id %}"> {{ prop.val1 }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val2 }} </TT> </td> | |
{% else %} | |
{% ifequal prop.val_champ 'module elasticite' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val1 }} </TT> </td> | |
<td width="150" <TT> {{ prop.val2 }} </TT> </td> | |
{% else %} | |
{% ifequal prop.val_champ 'masse volumique' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> | |
<td width="150" <TT> <a href="{% url lit_param2 prop.id %}"> {{ prop.val1 }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val2 }}</TT> </td> | |
{% else %} | |
{% ifequal prop.val_champ 'conductivite thermique' %} | |
<td width="150" <TT> <a href="{% url temp prop.id %}"> {{ prop.val_champ }} </a></TT> </td> | |
<td width="150" <TT> <a href="{% url lit_param3 prop.id %}"> {{ prop.val1 }} </a></TT> </td> | |
<td width="150" <TT> {{ prop.val2 }}</TT> </td> | |
{% else %} | |
<td width="150" <TT>{{ prop.val_champ}} </TT></td> | |
<td width="150" <TT> {{ prop.val1 }}</TT> </td> | |
<td width="150" <TT> {{ prop.val2 }}</TT> </td> | |
{% endifequal %} | |
{% endifequal %} | |
{% endifequal %} | |
{% endifequal %} | |
<td width="150" <TT> {{ prop.val_unit }} </TT></td> | |
</tr> | |
</div> | |
</table> | |
{% endifchanged %} | |
{% endfor %} | |
</ul> | |
<a href="javascript:history.go(-1)">Retour liste</a> | | |
<a href="{% url edition_media object.pk %}">Edition du formulaire medias </a> | <a href="{% url edition object.pk %}">Edition du formulaire general </a> | <a href="{% url edit object.pk %}">Edition du formulaire temperatures </a> | |
|<a href="{% url delete object.id %}">Supression des donnees materiau </a> | |
{% else %} | |
<font size="3" color="black">aucune donnee materiau...</font> | |
<a href="{% url edition object.pk %}">Edition du formulaire general </a> | <a href="{% url delete object.id %}">Supression des donnees materiau </a> | | |
<a href="javascript:history.go(-1)">Retour liste </a> | |
{#<a href="{% url record %}">Insertion donnees</a> | #} | |
{% endif %} | |
</div> | |
</body> | |
{% endblock %} | |
views.py | |
def manage3_materiaux(request, material_id=None): | |
if material_id== None: | |
material = Material() | |
else: | |
material = Material.objects.get(id = material_id) | |
MaterialFormset = inlineformset_factory(Material, Temp_exp, can_delete=True) | |
if request.method == "POST": | |
materialform = MaterialForm(request.POST, instance=material) | |
materialformset = MaterialFormset(request.POST,request.FILES, instance=material) | |
if materialform.is_valid(): | |
materialform.save() | |
else: | |
pass | |
if materialformset.is_valid(): | |
materialformset.save() | |
else: | |
pass | |
# if '_save' in request.POST: | |
# return HttpResponseRedirect(reverse('materiaux_material_list')) | |
# if '_addanother' in request.POST: | |
# return HttpResponseRedirect(reverse('materiaux_material_list')) | |
else: | |
materialform = MaterialForm(instance=material) | |
materialformset = MaterialFormset(instance=material) | |
return render_to_response('materiaux/edit_tableau.html', { | |
'material_id': material_id, | |
'materialform': materialform, | |
'materialformset' : materialformset, | |
}) | |
def lit_propriete(request, id): | |
return object_detail(request, | |
queryset= Temp_exp.objects.all(), | |
object_id=id, | |
template_name='materiaux/lit_prop.html', | |
template_object_name ='temp1' | |
) | |
urls.py | |
url(r'^pastes/(?P<id>\d+)$', 'monprojet.materiaux.views.lit_propriete', name='temp'), | |
url(r'^temp/(?P<material_id>[-\w]+)$', 'monprojet.materiaux.views.manage3_materiaux', name='edit'), | |
models.py | |
class Material(models.Model): | |
name = models.CharField(_('name'), max_length=50) | |
description = models.TextField(_('description'), blank=True) | |
slug = models.SlugField() | |
category = models.ForeignKey(Category, verbose_name=_('category')) | |
def get_physical_properties(self): | |
return self.uniteproperty1_set.all() | |
def get_medias(self): | |
return self.media2_set.all() | |
@models.permalink | |
def get_absolute_url(self): | |
return ('materiaux_material_detail', (), {'slug': self.slug}) | |
def __unicode__(self): | |
return self.name | |
class Meta: | |
verbose_name = _('material') | |
verbose_name_plural = _('materials') | |
ordering = ['name'] | |
class Property(models.Model): | |
name = models.CharField(_('name'), max_length=50) | |
description = models.TextField(_('description'), blank=True) | |
def __unicode__(self): | |
return self.name | |
class Meta: | |
verbose_name = _('property') | |
verbose_name_plural = _('properties') | |
ordering = ['name'] | |
class MaterialProperty(models.Model): | |
material = models.ForeignKey(Material, verbose_name=_('material')) | |
property_name = models.ForeignKey(Property, verbose_name=_('property')) | |
value = models.TextField(_('value')) | |
def __unicode__(self): | |
return '%s %s: %s' % (self.material.name, self.property_name.name, self.value) | |
class Meta: | |
verbose_name = _('material property') | |
verbose_name_plural = _('material properties') | |
class UniteProperty1(models.Model): | |
name = models.ForeignKey(Material, verbose_name=_('name')) # Al2O3.... | |
nature_unit = models.ForeignKey(Property, verbose_name=_('nature_unit')) # mecanique, thermique... | |
val_champ = models.CharField(_('val_champ'), max_length=150) # durete Vickers.... | |
val1= models.FloatField(blank=True, null=False) # valeur numerique min | |
val2= models.FloatField(blank=True, null=False) # valeur numerique max | |
val_unit = models.CharField(_('val_unit'), max_length=50, choices = UNIT)# unite (GPa, Kg,....) | |
def __unicode__(self): | |
return '%s' % (self.name) | |
class Meta: | |
verbose_name = _('parameter') | |
verbose_name_plural = _('parametres') | |
ordering = ['nature_unit'] | |
class Temp_exp(models.Model): | |
name = models.ForeignKey(Material, verbose_name=_('name')) # Al2O3.... | |
nature_unit = models.ForeignKey(Property, verbose_name=_('nature_unit')) # mecanique, thermique... | |
val_champ20 = models.CharField(_('val_champ1'), max_length=50) # durete Vickers.... | |
val_T20 = models.IntegerField(blank=True, null=False) # temperatue experimentale | |
val_min20= models.FloatField(blank=True, null=False) # valeur numerique min | |
val_max20= models.FloatField(blank=True, null=False) # valeur numerique max | |
val_unit20 = models.CharField(_('val_unit'), max_length=50, choices = UNIT) | |
val_champ200 = models.CharField(_('val_champ1'), max_length=50) # durete Vickers.... | |
val_T200 = models.IntegerField(blank=True, null=False) # temperatue experimentale | |
val_min200= models.FloatField(blank=True, null=False) # valeur numerique min | |
val_max200= models.FloatField(blank=True, null=False) # valeur numerique max | |
val_unit200 = models.CharField(_('val_unit'), max_length=50, choices = UNIT) | |
val_champ1000 = models.CharField(_('val_champ1'), max_length=50) # durete Vickers.... | |
val_T1000 = models.IntegerField(blank=True, null=False) # temperatue experimentale | |
val_min1000= models.FloatField(blank=True, null=False) # valeur numerique min | |
val_max1000= models.FloatField(blank=True, null=False) # valeur numerique max | |
val_unit1000 = models.CharField(_('val_unit'), max_length=50, choices = UNIT) | |
def __unicode__(self): | |
return '%s' % (self.name) | |
class Meta: | |
verbose_name_plural = _('proprietes en temperature') | |
lit_prop.html | |
{% extends "base.html" %} | |
{% block content %} | |
{% if temp1 %} | |
<body bgcolor="F7FBFA"> | |
<p align="left">Caracteristiques du materiau {{ temp1.name }} en fonction de la temperature</p> | |
<table width="140%" border="1" style="border: 0.5px;" cellspacing="0" cellpadding="0" BORDERCOLOR="black" > | |
<div> | |
<tr bgcolor="dddddd"> | |
<td width="140" <TT><strong>Propriete {{temp1.nature_unit}} </strong></TT></td> | |
<td width="140" <TT><strong>Temperature (°C)</strong></TT></td> | |
<td width="140" <TT><strong>Valeur min </strong></TT></td> | |
<td width="140" <TT><strong>Valeur max </strong></TT></td> | |
<td width="140" <TT><strong> Unite</strong></TT></td> | |
</tr> | |
<tr> | |
<td width="140" <TT>{{ temp1.val_champ20}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_T20}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_min20}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_max20}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_unit20}} </TT></td> | |
</tr> | |
<tr> | |
<td width="140" <TT>{{ temp1.val_champ200}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_T200}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_min200}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_max200}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_unit200}} </TT></td> | |
</tr> | |
<tr> | |
<td width="140" <TT>{{ temp1.val_champ1000}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_T1000}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_min1000}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_max1000}} </TT></td> | |
<td width="140" <TT>{{ temp1.val_unit1000}} </TT></td> | |
</tr> | |
</div> | |
</table> | |
</br> | |
{% else %} | |
<p>aucun materiau trouve suivant votre critere</p> | |
{% endif %} | |
<a href="javascript:history.go(-1)">Retour liste</a> | |
</body> | |
{% endblock %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment