stocke dans le record sa provenance
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / savoirs / models.py
CommitLineData
92c7413b 1# -*- encoding: utf-8 -*-
d15017b2 2from django.db import models
92c7413b
CR
3import uuid, datetime
4from timezones.fields import TimeZoneField
d15017b2
CR
5
6
7class Discipline(models.Model):
8 id = models.IntegerField(primary_key=True, db_column='id_discipline')
9 nom = models.CharField(max_length=765, db_column='nom_discipline')
6ef8ead4
CR
10
11 def __unicode__ (self):
92c7413b 12 return self.nom
6ef8ead4 13
d15017b2
CR
14 class Meta:
15 db_table = u'discipline'
16 ordering = ["nom",]
17
79c398f6
CR
18class SourceActualite(models.Model):
19 nom = models.CharField(max_length=255)
20 url = models.CharField(max_length=255)
21
d15017b2 22class Actualite(models.Model):
4f262f90 23 id = models.AutoField(primary_key=True, db_column='id_actualite')
d15017b2
CR
24 titre = models.CharField(max_length=765, db_column='titre_actualite')
25 texte = models.TextField(db_column='texte_actualite')
26 url = models.CharField(max_length=765, db_column='url_actualite')
27 logo = models.CharField(max_length=765, db_column='logo_actualite')
28 date = models.DateField(db_column='date_actualite')
29 visible = models.CharField(max_length=3, db_column='visible_actualite')
40a5ebfb 30 ancienid = models.IntegerField(db_column='ancienId_actualite')
6ef8ead4
CR
31
32 def __unicode__ (self):
33 return "Actualite %d: %s" % (self.id, self.titre)
34
d15017b2
CR
35 class Meta:
36 db_table = u'actualite'
37 ordering = ["-date",]
92c7413b
CR
38
39
40class ActiveManager(models.Manager):
41 def get_query_set(self):
42 return super(ActiveManager, self).get_query_set().filter(actif=True)
43
44class Evenement(models.Model):
45 actif = models.BooleanField(default = True)
46 uid = models.CharField(max_length = 255, default = uuid.uuid1)
47 approuve = models.BooleanField(default = False)
48 titre = models.CharField(max_length=255)
49 discipline = models.ForeignKey('Discipline', related_name = "discipline",
50 blank = True, null = True)
51 discipline_secondaire = models.ForeignKey('Discipline', related_name = \
52 "discipline_secondaire",
53 verbose_name = \
54 "Discipline secondaire",
55 blank = True, null = True)
56 mots_cles = models.TextField('Mots-Clés', blank = True, null = True)
57 type = models.CharField(max_length = 255, choices = \
58 (('Colloque', 'Colloque'),
59 ('Conférence', 'Conférence'),
60 ('Appel à contribution', 'Appel à contribution'),
61 ('Journée d\'étude', 'Journée d\'étude'),
62 (None, 'Autre')
63 )) #TODO: choices
64 fuseau = TimeZoneField(verbose_name = 'Fuseau horaire')
65 debut = models.DateTimeField(default = datetime.datetime.now)
66 fin = models.DateTimeField(default = datetime.datetime.now)
67 lieu = models.TextField()
68 description = models.TextField(blank = True, null = True)
69 #fichiers = TODO?
70 contact = models.TextField(blank = True, null = True)
71 url = models.CharField(max_length=255, blank = True, null = True)
72
73 objects = ActiveManager()
74
0cc5f772
CR
75
76class Record(models.Model):
77 id = models.AutoField(primary_key = True)
78 title = models.TextField(null = True, blank = True)
79 alt_title = models.TextField(null = True, blank = True)
80 creator = models.TextField(null = True, blank = True)
81 description = models.TextField(null = True, blank = True)
82 abstract = models.TextField(null = True, blank = True)
83 creation = models.CharField(max_length = 255, null = True, blank = True)
84 issued = models.CharField(max_length = 255, null = True, blank = True)
85 modified = models.CharField(max_length = 255, null = True, blank = True)
86 identifier = models.CharField(max_length = 255, null = True, blank = True, unique = True)
87 isbn = models.TextField(null = True, blank = True)
88 uri = models.CharField(max_length = 255, null = True, blank = True, unique = True)
89 source = models.TextField(null = True, blank = True)
90 contributor = models.TextField(null = True, blank = True)
91 subject = models.TextField(null = True, blank = True)
92 publisher = models.TextField(null = True, blank = True)
93 type = models.TextField(null = True, blank = True)
94 format = models.TextField(null = True, blank = True)
95 language = models.TextField(null = True, blank = True)
96 orig_lang = models.TextField(null = True, blank = True)
97
98 def __unicode__(self):
99 return "<R %s, %s>" % (self.id, self.subject)
100
101class HarvestLog(models.Model):
102 name = models.CharField(max_length = 255, primary_key = True)
103 date = models.DateTimeField(auto_now = True)
104 count = models.IntegerField(null = True, blank = True)