1
|
# -*- coding: utf-8 -*-
|
2
|
|
3
|
from django.db import models
|
4
|
from django.db.models import query
|
5
|
|
6
|
from calebasse.models import PhoneNumberField, ZipCodeField
|
7
|
|
8
|
from model_utils.managers import PassThroughManager
|
9
|
|
10
|
|
11
|
class ServiceLinkedQuerySet(query.QuerySet):
|
12
|
def for_service(self, service, allow_global=True):
|
13
|
'''Allows service local and service global objects'''
|
14
|
return self.filter(models.Q(service=service)
|
15
|
|models.Q(service__isnull=allow_global))
|
16
|
|
17
|
ServiceLinkedManager = PassThroughManager.for_queryset_class(ServiceLinkedQuerySet)
|
18
|
|
19
|
class NamedAbstractModel(models.Model):
|
20
|
name = models.CharField(max_length=80, verbose_name=u'Nom')
|
21
|
|
22
|
def __unicode__(self):
|
23
|
return self.name
|
24
|
|
25
|
def __repr__(self):
|
26
|
return '<%s %r>' % (self.__class__.__name__, unicode(self))
|
27
|
|
28
|
class Meta:
|
29
|
abstract = True
|
30
|
ordering = ['name']
|
31
|
|
32
|
class ServiceLinkedAbstractModel(models.Model):
|
33
|
objects = ServiceLinkedManager()
|
34
|
service = models.ForeignKey('Service', null=True, blank=True)
|
35
|
|
36
|
class Meta:
|
37
|
abstract = True
|
38
|
|
39
|
# Caisse d'assurance maladie
|
40
|
class HealthFund(NamedAbstractModel):
|
41
|
class Meta:
|
42
|
verbose_name = u'Caisse d\'assurances maladie'
|
43
|
verbose_name_plural = u'Caisses d\'assurances maladie'
|
44
|
|
45
|
abbreviation = models.CharField(max_length=8)
|
46
|
active = models.BooleanField(default=True)
|
47
|
address = models.CharField(max_length=120)
|
48
|
address_complement = models.CharField(max_length=120, blank=True,
|
49
|
null=True, default=None)
|
50
|
zip_code = models.IntegerField(max_length=8)
|
51
|
city = models.CharField(max_length=80)
|
52
|
phone = models.CharField(max_length=30)
|
53
|
fax = models.CharField(max_length=30)
|
54
|
email = models.EmailField()
|
55
|
accounting_number = models.CharField(max_length=30)
|
56
|
correspondant = models.CharField(max_length=80)
|
57
|
|
58
|
|
59
|
class TransportCompany(NamedAbstractModel):
|
60
|
class Meta:
|
61
|
verbose_name = u'Compagnie de transport'
|
62
|
verbose_name_plural = u'Compagnies de transport'
|
63
|
|
64
|
|
65
|
class CFTMEACode(NamedAbstractModel):
|
66
|
class Meta:
|
67
|
verbose_name = u'Code CFTMEA'
|
68
|
verbose_name_plural = u'Codes CFTMEA'
|
69
|
|
70
|
|
71
|
class UninvoicableCode(models.Model):
|
72
|
class Meta:
|
73
|
verbose_name = u'Code de non-facturation'
|
74
|
verbose_name_plural = u'Codes de non-facturation'
|
75
|
|
76
|
|
77
|
class Office(ServiceLinkedAbstractModel):
|
78
|
class Meta:
|
79
|
verbose_name = u'Établissement'
|
80
|
verbose_name_plural = u'Établissements'
|
81
|
|
82
|
def __unicode__(self):
|
83
|
return self.slug
|
84
|
|
85
|
slug = models.SlugField(verbose_name='Label')
|
86
|
description = models.TextField(blank=True, null=True)
|
87
|
|
88
|
# Contact
|
89
|
phone = PhoneNumberField(verbose_name=u"Téléphone", blank=True, null=True)
|
90
|
fax = PhoneNumberField(verbose_name=u"Fax", blank=True, null=True)
|
91
|
email = models.EmailField(blank=True, null=True)
|
92
|
|
93
|
# Address
|
94
|
address = models.CharField(max_length=120,
|
95
|
verbose_name=u"Addresse")
|
96
|
address_complement = models.CharField(max_length=120,
|
97
|
blank=True,
|
98
|
null=True,
|
99
|
default=None,
|
100
|
verbose_name=u"Complément d'addresse")
|
101
|
zip_code = ZipCodeField(verbose_name=u"Code postal")
|
102
|
#verbose_name=u"Code postal")
|
103
|
city = models.CharField(max_length=80,
|
104
|
verbose_name=u"Ville")
|
105
|
|
106
|
# TODO: add this fields : finess, suite, dm, dpa, genre, categorie, statut_juridique, mft, mt, dmt
|
107
|
|
108
|
class School(models.Model):
|
109
|
class Meta:
|
110
|
verbose_name = u'Lieu de scolarisation'
|
111
|
verbose_name_plural = u'Lieux de scolarisation'
|
112
|
|
113
|
def __unicode__(self):
|
114
|
return self.name
|
115
|
|
116
|
name = models.CharField(max_length=70, blank=False)
|
117
|
description = models.TextField()
|
118
|
address = models.CharField(max_length=120)
|
119
|
address_complement = models.CharField(max_length=120,
|
120
|
blank=True,
|
121
|
null=True,
|
122
|
default=None)
|
123
|
zip_code = ZipCodeField(verbose_name=u"Code postal")
|
124
|
city = models.CharField(max_length=80)
|
125
|
phone = PhoneNumberField(verbose_name=u"Téléphone")
|
126
|
fax = models.CharField(max_length=30)
|
127
|
email = models.EmailField()
|
128
|
director_name = models.CharField(max_length=70)
|
129
|
|
130
|
class SchoolTeacherRole(NamedAbstractModel):
|
131
|
class Meta:
|
132
|
verbose_name = u'Type de rôle des professeurs'
|
133
|
verbose_name_plural = u'Types de rôle des professeurs'
|
134
|
|
135
|
class InscriptionMotive(NamedAbstractModel):
|
136
|
class Meta:
|
137
|
verbose_name = u'Motif d\'inscription'
|
138
|
verbose_name_plural = u'Motifs d\'inscription'
|
139
|
|
140
|
|
141
|
class Nationality(NamedAbstractModel):
|
142
|
class Meta:
|
143
|
verbose_name = u'Nationalité'
|
144
|
verbose_name_plural = u'Nationalités'
|
145
|
|
146
|
|
147
|
class Job(NamedAbstractModel):
|
148
|
class Meta:
|
149
|
verbose_name = u'Profession'
|
150
|
verbose_name_plural = u'Professions'
|
151
|
|
152
|
|
153
|
class RoomQuerySet(query.QuerySet):
|
154
|
def for_etablissement(self, etablissement):
|
155
|
return self.filter(etablissement=etablissement)
|
156
|
|
157
|
def for_service(self, service):
|
158
|
return self.filter(etablissement__service=service)
|
159
|
|
160
|
|
161
|
class Room(NamedAbstractModel):
|
162
|
objects = PassThroughManager.for_queryset_class(RoomQuerySet)()
|
163
|
etablissement = models.ForeignKey('Office')
|
164
|
|
165
|
class Meta:
|
166
|
verbose_name = u'Salle'
|
167
|
verbose_name_plural = u'Salles'
|
168
|
|
169
|
|
170
|
class Service(NamedAbstractModel):
|
171
|
admin_only = True
|
172
|
|
173
|
slug = models.SlugField()
|
174
|
description = models.TextField()
|
175
|
|
176
|
# Contact
|
177
|
phone = PhoneNumberField(verbose_name=u"Téléphone")
|
178
|
fax = PhoneNumberField(verbose_name=u"Fax")
|
179
|
email = models.EmailField()
|
180
|
|
181
|
class Meta:
|
182
|
verbose_name = u'Service'
|
183
|
verbose_name_plural = u'Services'
|
184
|
|
185
|
class ActTypeQuerySet(query.QuerySet):
|
186
|
def for_service(self, service):
|
187
|
return self.filter(service=service)
|
188
|
|
189
|
class ActType(NamedAbstractModel, ServiceLinkedAbstractModel):
|
190
|
objects = PassThroughManager.for_queryset_class(ActTypeQuerySet)()
|
191
|
billable = models.BooleanField(default=True)
|
192
|
|
193
|
class Meta(NamedAbstractModel.Meta):
|
194
|
verbose_name = u'Type d\'actes'
|
195
|
verbose_name_plural = u'Types d\'actes'
|
196
|
|
197
|
class ParentalAuthorityType(NamedAbstractModel):
|
198
|
class Meta:
|
199
|
verbose_name = u'Type d\'autorité parentale'
|
200
|
verbose_name_plural = u'Types d\'autorités parentales'
|
201
|
|
202
|
|
203
|
class ParentalCustodyType(NamedAbstractModel):
|
204
|
class Meta:
|
205
|
verbose_name = u'Type de gardes parentales'
|
206
|
verbose_name_plural = u'Types de gardes parentales'
|
207
|
|
208
|
|
209
|
class SessionType(NamedAbstractModel):
|
210
|
class Meta:
|
211
|
verbose_name = u'Type de séance'
|
212
|
verbose_name_plural = u'Types de séances'
|
213
|
|
214
|
|
215
|
class FamilySituationType(NamedAbstractModel):
|
216
|
class Meta:
|
217
|
verbose_name = u'Type de situation familiale'
|
218
|
verbose_name_plural = u'Types de situations familiales'
|
219
|
|
220
|
|
221
|
class TransportType(NamedAbstractModel):
|
222
|
class Meta:
|
223
|
verbose_name = u'Type de transport'
|
224
|
verbose_name_plural = u'Types de transports'
|
225
|
|
226
|
|
227
|
class WorkerType(NamedAbstractModel):
|
228
|
intervene = models.BooleanField(
|
229
|
verbose_name=u'Intervenant',
|
230
|
blank=True)
|
231
|
|
232
|
class Meta:
|
233
|
verbose_name = u'Type de personnel'
|
234
|
verbose_name_plural = u'Types de personnel'
|
235
|
|