model is valid

This commit is contained in:
Fred Pauchet 2012-03-30 14:40:58 +02:00
parent 4968769b29
commit 19b73bd3a1
6 changed files with 43 additions and 17 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
#coding=utf-8
#coding=utf-8
from django.db import models
@ -6,28 +6,33 @@ class Country(models.Model):
name = models.CharField(verbose_name='Pays', max_length=50)
class Meta:
verbose_name_pluralize='Pays'
verbose_name_plural ='Pays'
class Category(models.Model):
label = models.CharField(verbose_name='Label', max_length=50)
label = models.CharField(verbose_name='Catégorie', max_length=50)
class Meta:
verbose_name_pluralize='Catégories'
verbose_name_plural ='Catégories'
class SubCategory(models.Model):
label = models.CharField(verbose_name='Sous-catégorie', max_length=50)
label = models.CharField(verbose_name='Thème', max_length=50)
class Meta:
verbose_name_pluralize='Sous-catégories'
verbose_name_plural ='Thèmes'
class Item(models.Model):
country = models.ForeignKey(Country)
category = models.ForeignKey(Category)
subcategory = models.ForeignKey(SubCategory)
label = models.CharField(verbose_name='Label', max_length=50)
country = models.ForeignKey(Country, verbose_name='Pays')
category = models.ForeignKey(Category, verbose_name='Catégorie')
subcategory = models.ForeignKey(SubCategory, verbose_name='Thème')
label = models.CharField(verbose_name='Titre', max_length=50)
image = models.ImageField(upload_to='pictures')
with_chip = models.BooleanField(verbose_name='Avec ou sans puce')
units = models.IntegerField(verbose_name="Nombre d'unités")
emissionDate = models.DateTimeField(verbose_name="Année d'émission")
expirationDate = models.DateTimeField(verbose_name="Année d'expiration")
numberOfCopies = models.IntegerField(verbose_name='Tirage')
class Meta:
verbose_name_pluralize='Items'
verbose_name_plural ='Items'

View File

@ -239,7 +239,7 @@
gcsfield3="france/Alimentation/Gourmandises/milka 50.jpg"
gcsfield4="Gourmandises"
gcsfield5="50"
gcsfield6="Milka Lila Pause"
gcsfield6="Milka Lila Pause"
gcsfield7="02/1996"
gcsfield8=""
gcsfield9="B61013013"

View File

@ -1,10 +1,32 @@
#coding=utf-8
from lxml import etree
import os
def process():
"""
Ouvre un fichier GCStar structuré de la manière suivante:
<collection...>
<item
gcsfield1="France" => pays
gcsfield2="1" => avec ou sans puce
gcsfield3="france/Alimentation/Gourmandises/milka 50.jpg" => image
gcsfield4="Gourmandises" => souscatégorie
gcsfield5="50" => unités
gcsfield6="Milka Lila Pause" => label
gcsfield7="02/1996" => année d'émission
gcsfield8="" => date d'expiration
gcsfield9="B61013013" => pas utile
gcsfield10="1000000" => tirage
gcsfield11="Alimentation " => catégorie
gcsautoid="19" => nafout
>
</collection>
"""
a = r'collection.gcs'
element = etree.parse(a)
items = element.xpath('//Collection')
items = element.xpath('//collection/item')
for item in items:
print item

View File

@ -115,10 +115,9 @@ INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'django.contrib.admin',
'django.contrib.admindocs',
'cards',
)
# A sample logging configuration. The only tangible logging

Binary file not shown.