1 # -*- coding: utf-8 -*-
2 #***************************************************************************
3 #* Copyright (C) 2015 Polytechnique.org *
4 #* http://opensource.polytechnique.org/ *
6 #* This program is free software; you can redistribute it and/or modify *
7 #* it under the terms of the GNU General Public License as published by *
8 #* the Free Software Foundation; either version 2 of the License, or *
9 #* (at your option) any later version. *
11 #* This program is distributed in the hope that it will be useful, *
12 #* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 #* GNU General Public License for more details. *
16 #* You should have received a copy of the GNU General Public License *
17 #* along with this program; if not, write to the Free Software *
18 #* Foundation, Inc., *
19 #* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 #***************************************************************************/
21 """Django models which fit the latest version of Plat/al database
23 Latest version synced: Plat/al 1.1.15
24 https://github.com/Polytechnique-org/platal/tree/xorg/maint/upgrade
26 cf. https://docs.djangoproject.com/en/dev/howto/legacy-databases/
28 This requires Django to work.
30 from __future__
import unicode_literals
33 from django
.db
import models
34 from django
.utils
.encoding
import python_2_unicode_compatible
37 def is_ax_visible(field
):
38 return field
in ('public', 'ax')
41 # Misc for Account/Profile
42 # ========================
45 @python_2_unicode_compatible
46 class Skin(models
.Model
):
47 id = models
.IntegerField(primary_key
=True)
48 name
= models
.CharField(max_length
=96)
49 date
= models
.DateField()
50 comment
= models
.CharField(max_length
=765)
51 auteur
= models
.CharField(max_length
=90)
52 skin_tpl
= models
.CharField(max_length
=96)
53 ext
= models
.CharField(max_length
=9)
62 @python_2_unicode_compatible
63 class EmailVirtualDomain(models
.Model
):
64 id = models
.IntegerField(primary_key
=True)
65 name
= models
.CharField(max_length
=765)
66 aliasing
= models
.ForeignKey('self', db_column
='aliasing')
69 db_table
= 'email_virtual_domains'
75 @python_2_unicode_compatible
76 class ProfileSectionEnum(models
.Model
):
77 id = models
.IntegerField(primary_key
=True)
78 text
= models
.CharField(max_length
=150, unique
=True)
81 db_table
= 'profile_section_enum'
87 @python_2_unicode_compatible
88 class GeolocCountry(models
.Model
):
89 iso_3166_1_a2
= models
.CharField(max_length
=6, primary_key
=True)
90 iso_3166_1_a3
= models
.CharField(max_length
=9, unique
=True)
91 iso_3166_1_num
= models
.IntegerField(unique
=True)
92 worldregion
= models
.CharField(max_length
=6, db_column
='worldRegion', blank
=True) # Field name made lowercase.
93 country
= models
.CharField(max_length
=765, blank
=True)
94 countryen
= models
.CharField(max_length
=765, db_column
='countryEn', blank
=True) # Field name made lowercase.
95 capital
= models
.CharField(max_length
=765)
96 nationality
= models
.CharField(max_length
=765, blank
=True)
97 nationalityen
= models
.CharField(max_length
=765, db_column
='nationalityEn', blank
=True) # Field name made lowercase.
98 phoneprefix
= models
.IntegerField(null
=True, db_column
='phonePrefix', blank
=True) # Field name made lowercase.
99 phoneformat
= models
.CharField(max_length
=765, db_column
='phoneFormat') # Field name made lowercase.
100 licenseplate
= models
.CharField(max_length
=12, db_column
='licensePlate', blank
=True) # Field name made lowercase.
101 belongsto
= models
.ForeignKey('self', null
=True, db_column
='belongsTo', blank
=True) # Field name made lowercase.
102 countryplain
= models
.CharField(max_length
=765, db_column
='countryPlain', blank
=True) # Field name made lowercase.
105 db_table
= 'geoloc_countries'
108 return self
.iso_3166_1_a2
115 @python_2_unicode_compatible
116 class AccountType(models
.Model
):
117 type = models
.CharField(max_length
=48, primary_key
=True)
118 perms
= models
.CharField(max_length
=321)
119 description
= models
.TextField(blank
=True)
122 db_table
= 'account_types'
128 @python_2_unicode_compatible
129 class Account(models
.Model
):
130 uid
= models
.AutoField(primary_key
=True)
131 hruid
= models
.CharField(max_length
=255, unique
=True)
132 type = models
.ForeignKey(AccountType
, null
=True, db_column
='type', blank
=True)
133 user_perms
= models
.CharField(max_length
=288, blank
=True)
134 is_admin
= models
.BooleanField()
135 state
= models
.CharField(max_length
=24)
136 password
= models
.CharField(max_length
=120, blank
=True)
137 token
= models
.CharField(max_length
=96, blank
=True)
138 weak_password
= models
.CharField(max_length
=768, blank
=True)
139 registration_date
= models
.DateTimeField()
140 flags
= models
.CharField(max_length
=15)
141 comment
= models
.CharField(max_length
=765, blank
=True)
142 email
= models
.CharField(max_length
=765, blank
=True)
143 firstname
= models
.CharField(max_length
=765, blank
=True)
144 lastname
= models
.CharField(max_length
=765, blank
=True)
145 full_name
= models
.CharField(max_length
=765, blank
=True)
146 directory_name
= models
.CharField(max_length
=765, blank
=True)
147 sort_name
= models
.CharField(max_length
=765, blank
=True)
148 display_name
= models
.CharField(max_length
=765, blank
=True)
149 sex
= models
.CharField(max_length
=18)
150 email_format
= models
.CharField(max_length
=12)
151 skin
= models
.ForeignKey(Skin
, null
=True, db_column
='skin', blank
=True)
152 last_version
= models
.CharField(max_length
=48)
153 best_domain
= models
.ForeignKey(EmailVirtualDomain
, null
=True, db_column
='best_domain', blank
=True)
154 from_email
= models
.CharField(max_length
=765)
155 from_format
= models
.CharField(max_length
=12)
158 db_table
= 'accounts'
161 return '%s (%s)' %
(self
.hruid
, self
.full_name
)
165 return self
.profiles
.filter(perms
='owner').get().profile
168 @python_2_unicode_compatible
169 class ProfileAlias(object):
170 def __init__(self
, alias_of
, kind
, lastname
, firstname
=None):
171 self
.alias_of
= alias_of
173 self
.lastname
= lastname
174 self
.firstname
= alias_of
.firstname
if firstname
is None else firstname
176 ALT_MARITAL
= 'marital'
177 ALT_PSEUDO
= 'pseudo'
178 ALT_ORDINARY
= 'ordinary'
182 return self
.kind
== self
.ALT_PSEUDO
184 def get_kind_display(self
):
185 if self
.kind
== self
.ALT_MARITAL
:
190 elif self
.kind
== self
.ALT_PSEUDO
:
195 def __getattr__(self
, attr
):
196 return getattr(self
.alias_of
, attr
)
199 return '<ProfileAlias %s of %r>' %
(self
.kind
, self
.alias_of
)
202 @python_2_unicode_compatible
203 class Profile(models
.Model
):
207 def __init__(self
, *args
, **kwargs
):
208 super(Profile
, self
).__init__(*args
, **kwargs
)
211 pid
= models
.AutoField(primary_key
=True)
212 hrpid
= models
.CharField(max_length
=255, unique
=True)
213 xorg_id
= models
.IntegerField()
214 ax_id
= models
.CharField(max_length
=24, blank
=True)
215 birthdate
= models
.DateField(null
=True, blank
=True)
216 birthdate_ref
= models
.DateField(null
=True, blank
=True)
217 next_birthday
= models
.DateField(null
=True, blank
=True)
218 deathdate
= models
.DateField(null
=True, blank
=True)
219 deathdate_rec
= models
.DateField(null
=True, blank
=True)
220 sex
= models
.CharField(max_length
=18)
221 section
= models
.ForeignKey(ProfileSectionEnum
, null
=True, db_column
='section', blank
=True)
222 cv
= models
.TextField(blank
=True)
223 freetext
= models
.TextField(blank
=True)
224 freetext_pub
= models
.CharField(max_length
=21)
225 medals_pub
= models
.CharField(max_length
=21)
226 alias_pub
= models
.CharField(max_length
=21)
227 nationality1
= models
.ForeignKey(GeolocCountry
, null
=True, db_column
='nationality1', blank
=True, related_name
='natives')
228 nationality2
= models
.ForeignKey(GeolocCountry
, null
=True, db_column
='nationality2', blank
=True, related_name
='second_natives')
229 nationality3
= models
.ForeignKey(GeolocCountry
, null
=True, db_column
='nationality3', blank
=True, related_name
='third_natives')
230 email_directory
= models
.CharField(max_length
=765, blank
=True)
231 last_change
= models
.DateField()
232 title
= models
.CharField(max_length
=12)
235 db_table
= 'profiles'
242 return self
.deathdate
is None
246 return self
.accounts
.filter(perms
='owner').get().account
250 return self
.public_name
.firstname_ordinary
or self
.public_name
.firstname_main
or self
.public_name
.firstname_initial
254 return self
.public_name
.lastname_main
or self
.public_name
.lastname_initial
257 def lastname_display(self
):
258 return self
.public_name
.lastname_ordinary
or self
.public_name
.lastname_marital
or self
.public_name
.lastname_main
or self
.public_name
.lastname_initial
261 def lastname_marital(self
):
262 return self
.public_name
.lastname_marital
265 def lastname_ordinary(self
):
266 return self
.public_name
.lastname_ordinary
270 return self
.public_name
.pseudonym
274 return self
.profiledisplay
.promo
278 return self
.sex
== 'female'
281 def nationality(self
):
282 return self
.nationality1
or self
.nationality2
or self
.nationality3
285 def country_code(self
):
286 nat
= self
.nationality
289 return nat
.iso_3166_1_a2
292 def country_name(self
):
293 nat
= self
.nationality
299 def current_corps(self
):
301 return self
.profilecorps
.current
302 except ProfileCorps
.DoesNotExist
:
305 def get_aliases(self
, include_deviations
=True):
306 if self
._aliases
is None:
309 alt_names
= set([self
.lastname
])
310 if self
.lastname_marital
and self
.lastname_marital
not in alt_names
:
311 alt_names
.add(self
.lastname_marital
)
312 self
._aliases
.append(
313 ProfileAlias(self
, ProfileAlias
.ALT_MARITAL
, self
.lastname_marital
))
315 if self
.lastname_ordinary
and self
.lastname_ordinary
not in alt_names
:
316 # Some people filled 'ordinary' instead of 'marital'
317 alt_names
.add(self
.lastname_ordinary
)
318 self
._aliases
.append(
319 ProfileAlias(self
, ProfileAlias
.ALT_ORDINARY
, self
.lastname_ordinary
))
321 if self
.pseudonym
and self
.pseudonym
not in alt_names
:
322 alt_names
.add(self
.pseudonym
)
323 self
._aliases
.append(
324 ProfileAlias(self
, ProfileAlias
.ALT_PSEUDO
, self
.pseudonym
, firstname
=''))
326 if include_deviations
:
329 return [a
for a
in self
._aliases
330 if not a
.lastname
.startswith(self
.lastname
)
331 and not self
.lastname
.startswith(a
.lastname
)
335 def mobile_line(self
):
336 if not hasattr(self
, '_mobiles'):
338 for phone
in self
.phones
.all()
339 if phone
.link_type
== phone
.LINK_USER
and phone
.tel_type
== phone
.KIND_MOBILE
341 self
._mobiles
= sorted(mobiles
, key
=lambda p
: p
.tel_id
)
343 return self
._mobiles
[0]
346 def sorted_addresses(self
, for_ax
=False):
347 personal_addresses
= [addr
348 for addr
in self
.addresses
.all()
349 if addr
.is_home
and (addr
.ax_visible
or not for_ax
)
352 address_phones
= collections
.defaultdict(lambda: collections
.defaultdict(list))
354 for phone
in self
.phones
.all():
355 if phone
.is_address
and (phone
.ax_visible
or not for_ax
):
356 address_phones
[phone
.link_id
][phone
.tel_type
].append(phone
)
358 for address
in personal_addresses
:
360 for kind
, phones
in address_phones
[address
.subid
].items():
362 addr_phones
[kind
] = sorted(phones
, key
=lambda p
: p
.tel_id
)[0]
364 addr_phones
[kind
] = None
365 address
.phones
= addr_phones
367 current
= [addr
for addr
in personal_addresses
if addr
.current
]
368 secondary
= [addr
for addr
in personal_addresses
if addr
.secondary
and not addr
.current
]
370 current
, secondary
= secondary
, []
372 return [(a
, True) for a
in current
] + [(a
, False) for a
in secondary
]
374 def sorted_educations(self
):
375 edus
= [edu
for edu
in self
.educations
.all() if edu
.school
and edu
.school
.abbreviation
!= 'X']
376 return sorted(edus
, key
=lambda edu
: edu
.entry_year
)
378 def sorted_jobs(self
):
379 jobs
= sorted(self
.jobs
.all(), key
=lambda j
: (j
.id, j
.entry_year
))
381 for addr
in self
.addresses
.all():
383 job_addresses
[addr
.job_id
] = addr
385 job_phones
= collections
.defaultdict(lambda: collections
.defaultdict(list))
386 for phone
in self
.phones
.all():
388 job_phones
[phone
.link_id
][phone
.tel_type
].append(phone
)
391 job
.address
= job_addresses
.get(job
.id)
393 for kind
, phones
in job_phones
[job
.id].items():
395 j_phones
[kind
] = sorted(phones
, key
=lambda p
: p
.tel_id
)[0]
397 j_phones
[kind
] = None
398 job
.phones
= j_phones
403 @python_2_unicode_compatible
404 class AccountProfile(models
.Model
):
405 account
= models
.ForeignKey(Account
, db_column
='uid', related_name
='profiles')
406 profile
= models
.ForeignKey(Profile
, db_column
='pid', related_name
='accounts')
407 perms
= models
.CharField(max_length
=15)
410 db_table
= 'account_profiles'
411 unique_together
= (('uid', 'pid'),)
414 return '%s -> %s' %
(self
.account
.hruid
, self
.profile
.hrpid
)
421 @python_2_unicode_compatible
422 class AccountAuthOpenid(models
.Model
):
423 id = models
.IntegerField(primary_key
=True)
424 account
= models
.ForeignKey(Account
, unique
=True, null
=True, db_column
='uid', blank
=True)
425 url
= models
.CharField(max_length
=255, unique
=True)
428 db_table
= 'account_auth_openid'
431 return "%s at %s" %
(self
.account
, self
.url
)
433 @python_2_unicode_compatible
434 class AccountLostPassword(models
.Model
):
435 certificat
= models
.CharField(max_length
=96, primary_key
=True)
436 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
437 created
= models
.DateTimeField(null
=True, blank
=True)
440 db_table
= 'account_lost_passwords'
443 return "%s on %s" %
(self
.account
.hruid
, self
.created
)
446 @python_2_unicode_compatible
447 class AccountXnetLostPassword(models
.Model
):
448 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid')
449 date
= models
.DateTimeField(null
=True, blank
=True)
450 hash = models
.CharField(max_length
=96)
453 db_table
= 'account_xnet_lost_passwords'
456 return "%s on %s" %
(self
.account
.hruid
, self
.date
)
463 @python_2_unicode_compatible
464 class Announce(models
.Model
):
465 id = models
.IntegerField(primary_key
=True)
466 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
467 creation_date
= models
.DateTimeField()
468 titre
= models
.CharField(max_length
=765)
469 texte
= models
.TextField()
470 expiration
= models
.DateField()
471 promo_min
= models
.IntegerField()
472 promo_max
= models
.IntegerField()
473 flags
= models
.CharField(max_length
=87)
474 noinvite
= models
.IntegerField()
475 post_id
= models
.IntegerField(null
=True, blank
=True, editable
=False,
476 help_text
="NNTP post identifier")
479 db_table
= 'announces'
482 return "%s: %s" %
(self
.id, self
.titre
)
485 @python_2_unicode_compatible
486 class AnnouncePhoto(models
.Model
):
487 eid
= models
.ForeignKey(Announce
, primary_key
=True, db_column
='eid')
488 attachmime
= models
.CharField(max_length
=12)
489 attach
= models
.TextField()
490 x
= models
.IntegerField()
491 y
= models
.IntegerField()
494 db_table
= 'announce_photos'
497 return "%s (%s, %d x %d)" %
(self
.eid
, self
.attachmime
, self
.x
, self
.y
)
500 @python_2_unicode_compatible
501 class AnnounceRead(models
.Model
):
502 evt
= models
.ForeignKey(Announce
)
503 account
= models
.ForeignKey(Account
, db_column
='uid')
506 db_table
= 'announce_read'
507 unique_together
= (('evt', 'uid'),)
510 return "%s: %s" %
(self
.account
, self
.evt
)
517 @python_2_unicode_compatible
518 class EmailVirtual(models
.Model
):
519 email
= models
.CharField(max_length
=255)
520 domain
= models
.ForeignKey(EmailVirtualDomain
, db_column
='domain')
521 redirect
= models
.CharField(max_length
=765)
522 type = models
.CharField(max_length
=21, blank
=True)
523 expire
= models
.DateField()
526 db_table
= 'email_virtual'
527 unique_together
= (('email', 'domain'),)
530 return "%s@%s (%s)" %
(self
.email
, self
.domain
, self
.type)
533 @python_2_unicode_compatible
534 class EmailRedirectAccount(models
.Model
):
535 account
= models
.ForeignKey(Account
, db_column
='uid')
536 redirect
= models
.CharField(max_length
=765)
537 rewrite
= models
.CharField(max_length
=765)
538 type = models
.CharField(max_length
=30)
539 action
= models
.CharField(max_length
=54)
540 broken_date
= models
.DateField()
541 broken_level
= models
.IntegerField()
542 last
= models
.DateField()
543 flags
= models
.CharField(max_length
=24)
544 hash = models
.CharField(max_length
=96, blank
=True)
545 allow_rewrite
= models
.BooleanField()
548 db_table
= 'email_redirect_account'
549 unique_together
= (('uid', 'redirect'),)
552 return "%s for %s (%s)" %
(self
.redirect
, self
.account
.hruid
, self
.type)
555 @python_2_unicode_compatible
556 class EmailSourceAccount(models
.Model
):
557 email
= models
.CharField(max_length
=255)
558 domain
= models
.ForeignKey(EmailVirtualDomain
, db_column
='domain')
559 account
= models
.ForeignKey(Account
, db_column
='uid')
560 type = models
.CharField(max_length
=9)
561 flags
= models
.CharField(max_length
=23)
562 expire
= models
.DateField(blank
=True, null
=True)
565 db_table
= 'email_source_account'
566 unique_together
= (('email', 'domain'),)
569 return "%s@%s (%s)" %
(self
.email
, self
.domain
, self
.type)
572 @python_2_unicode_compatible
573 class EmailSourceOther(models
.Model
):
574 email
= models
.CharField(max_length
=255)
575 domain
= models
.ForeignKey(EmailVirtualDomain
, db_column
='domain')
576 hrmid
= models
.CharField(max_length
=255)
577 type = models
.CharField(max_length
=8, blank
=True, null
=True)
578 expire
= models
.DateField(blank
=True, null
=True)
581 db_table
= 'email_source_other'
582 unique_together
= (('email', 'domain'),)
585 return "%s@%s (%s)" %
(self
.email
, self
.domain
, self
.type)
588 @python_2_unicode_compatible
589 class EmailRedirectOther(models
.Model
):
590 hrmid
= models
.ForeignKey(EmailSourceOther
, db_column
='hrmid')
591 redirect
= models
.CharField(max_length
=255)
592 type = models
.CharField(max_length
=10)
593 action
= models
.CharField(max_length
=18)
596 db_table
= 'email_redirect_other'
597 unique_together
= (('hrmid', 'redirect'),)
600 return "%s -> %s (%s)" %
(self
.hrmid
, self
.redirect
, self
.type)
607 @python_2_unicode_compatible
608 class InndForum(models
.Model
):
610 id_innd
= models
.AutoField(primary_key
=True)
611 ipmin
= models
.IntegerField(null
=True, blank
=True)
612 ipmax
= models
.IntegerField(null
=True, blank
=True)
613 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
614 read_perm
= models
.CharField(max_length
=300, blank
=True)
615 write_perm
= models
.CharField(max_length
=300, blank
=True)
616 priority
= models
.IntegerField(null
=True, blank
=True)
617 comment
= models
.TextField(blank
=True)
620 db_table
= 'forum_innd'
623 return "%d: %s" %
(self
.id_innd
, self
.account
.hruid
)
626 @python_2_unicode_compatible
627 class ForumProfile(models
.Model
):
628 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid')
629 name
= models
.CharField(max_length
=192)
630 mail
= models
.CharField(max_length
=210)
631 sig
= models
.TextField()
632 flags
= models
.CharField(max_length
=63)
633 tree_unread
= models
.CharField(max_length
=24)
634 tree_read
= models
.CharField(max_length
=24)
635 last_seen
= models
.DateTimeField()
638 db_table
= 'forum_profiles'
641 return "%s: %s" %
(self
.account
.hruid
, self
.name
)
644 @python_2_unicode_compatible
645 class Forum(models
.Model
):
646 fid
= models
.IntegerField(primary_key
=True)
647 name
= models
.CharField(max_length
=192)
656 @python_2_unicode_compatible
657 class ForumSubs(models
.Model
):
658 forum
= models
.ForeignKey(Forum
, db_column
='fid')
659 account
= models
.ForeignKey(Account
, db_column
='uid')
662 db_table
= 'forum_subs'
663 unique_together
= (('fid', 'uid'),)
666 return "%s by %s" %
(self
.forum
.name
, self
.account
.hruid
)
673 @python_2_unicode_compatible
674 class PaymentBankAccount(models
.Model
):
675 id = models
.IntegerField(primary_key
=True)
676 asso
= models
.ForeignKey('Group', blank
=True, null
=True)
677 iban
= models
.CharField(max_length
=33)
678 owner
= models
.CharField(max_length
=300)
679 status
= models
.CharField(max_length
=36)
680 bic
= models
.CharField(max_length
=11)
683 db_table
= 'payment_bankaccounts'
686 return '%s: %s' %
(self
.asso
.name
, self
.account
)
689 @python_2_unicode_compatible
690 class Payment(models
.Model
):
691 id = models
.IntegerField(primary_key
=True)
692 text
= models
.CharField(max_length
=765)
693 url
= models
.CharField(max_length
=384)
694 flags
= models
.CharField(max_length
=51)
695 amount_def
= models
.DecimalField(max_digits
=12, decimal_places
=2)
696 amount_min
= models
.DecimalField(max_digits
=12, decimal_places
=2)
697 amount_max
= models
.DecimalField(max_digits
=12, decimal_places
=2)
698 mail
= models
.CharField(max_length
=192)
699 confirmation
= models
.TextField()
700 asso
= models
.ForeignKey('Group', null
=True, blank
=True)
701 rib
= models
.ForeignKey(PaymentBankAccount
)
704 db_table
= 'payments'
707 return "%s: %s" %
(self
.id, self
.text
)
710 @python_2_unicode_compatible
711 class PaymentCodeC(models
.Model
):
712 id = models
.IntegerField(primary_key
=True)
713 text
= models
.CharField(max_length
=192)
716 db_table
= 'payment_codeC'
722 @python_2_unicode_compatible
723 class PaymentCodeRCB(models
.Model
):
724 id = models
.IntegerField(primary_key
=True)
725 text
= models
.CharField(max_length
=192)
726 codec
= models
.IntegerField(db_column
='codeC') # Field name made lowercase.
729 db_table
= 'payment_codeRCB'
735 @python_2_unicode_compatible
736 class PaymentMethod(models
.Model
):
737 id = models
.IntegerField(primary_key
=True)
738 text
= models
.CharField(max_length
=96)
739 include
= models
.CharField(max_length
=96)
740 short_name
= models
.CharField(max_length
=30)
741 flags
= models
.CharField(max_length
=36, blank
=True)
744 db_table
= 'payment_methods'
747 return self
.short_name
750 @python_2_unicode_compatible
751 class PaymentReconcilation(models
.Model
):
752 id = models
.IntegerField(primary_key
=True)
753 method
= models
.ForeignKey(PaymentMethod
)
754 period_start
= models
.DateField()
755 period_end
= models
.DateField()
756 status
= models
.CharField(max_length
=33)
757 payment_count
= models
.IntegerField()
758 sum_amounts
= models
.DecimalField(max_digits
=11, decimal_places
=2)
759 sum_commissions
= models
.DecimalField(max_digits
=11, decimal_places
=2)
760 comments
= models
.TextField()
761 recongroup_id
= models
.IntegerField(null
=True, blank
=True)
764 db_table
= 'payment_reconcilations'
767 return "%s: %s" %
(self
.method
, self
.status
)
770 @python_2_unicode_compatible
771 class PaymentTransaction(models
.Model
):
772 id = models
.CharField(max_length
=192, primary_key
=True)
773 method
= models
.ForeignKey(PaymentMethod
, null
=True, blank
=True)
774 account
= models
.ForeignKey(Account
, db_column
='uid')
775 ref
= models
.IntegerField()
776 fullref
= models
.CharField(max_length
=45)
777 ts_confirmed
= models
.DateTimeField(null
=True, blank
=True)
778 ts_initiated
= models
.DateTimeField(null
=True, blank
=True)
779 amount
= models
.DecimalField(max_digits
=11, decimal_places
=2)
780 commission
= models
.DecimalField(null
=True, max_digits
=11, decimal_places
=2, blank
=True)
781 pkey
= models
.CharField(max_length
=15)
782 comment
= models
.CharField(max_length
=765)
783 status
= models
.CharField(max_length
=27)
784 recon
= models
.ForeignKey(PaymentReconcilation
, null
=True, blank
=True)
785 display
= models
.IntegerField()
788 db_table
= 'payment_transactions'
791 return "%s (%s)" %
(self
.fullref
, self
.ref
)
794 @python_2_unicode_compatible
795 class PaymentTransfer(models
.Model
):
796 id = models
.IntegerField(primary_key
=True)
797 recongroup_id
= models
.IntegerField()
798 payment
= models
.ForeignKey(Payment
)
799 amount
= models
.DecimalField(max_digits
=11, decimal_places
=2)
800 account
= models
.ForeignKey(Account
, null
=True, blank
=True)
801 message
= models
.CharField(max_length
=765)
802 date
= models
.DateField(null
=True, blank
=True)
805 db_table
= 'payment_transfers'
808 return "%s: %s" %
(self
.id, self
.amount
)
815 @python_2_unicode_compatible
816 class GroupDom(models
.Model
):
817 id = models
.IntegerField(primary_key
=True)
818 name
= models
.TextField(db_column
='nom')
819 cat
= models
.CharField(max_length
=117)
822 db_table
= 'group_dom'
825 return "%s :: %s" %
(self
.cat
, self
.name
)
828 @python_2_unicode_compatible
829 class Group(models
.Model
):
830 id = models
.IntegerField(primary_key
=True)
831 name
= models
.CharField(max_length
=765, db_column
='nom')
832 diminutif
= models
.CharField(max_length
=192, unique
=True)
833 cat
= models
.CharField(max_length
=117)
834 dom
= models
.ForeignKey(GroupDom
, null
=True, db_column
='dom', blank
=True)
835 descr
= models
.TextField()
836 logo
= models
.TextField(blank
=True)
837 logo_mime
= models
.TextField(blank
=True)
838 site
= models
.CharField(max_length
=765)
839 mail
= models
.CharField(max_length
=765)
840 resp
= models
.CharField(max_length
=765)
841 forum
= models
.CharField(max_length
=765)
842 mail_domain
= models
.CharField(max_length
=765)
843 ax
= models
.IntegerField()
844 pub
= models
.CharField(max_length
=21)
845 sub_url
= models
.CharField(max_length
=765)
846 inscriptible
= models
.IntegerField()
847 unsub_url
= models
.CharField(max_length
=765)
848 flags
= models
.CharField(max_length
=117)
849 axdate
= models
.DateField(null
=True, db_column
='axDate', blank
=True) # Field name made lowercase.
850 welcome_msg
= models
.TextField(blank
=True)
851 event_order
= models
.CharField(max_length
=8)
852 disable_mails
= models
.BooleanField()
853 status
= models
.CharField(max_length
=117)
866 @python_2_unicode_compatible
867 class GroupMember(models
.Model
):
868 asso
= models
.ForeignKey(Group
)
869 account
= models
.ForeignKey(Account
, db_column
='uid')
870 perms
= models
.CharField(max_length
=6)
871 comm
= models
.CharField(max_length
=255, blank
=True, null
=True)
872 position
= models
.CharField(max_length
=18, blank
=True, null
=True)
873 flags
= models
.CharField(max_length
=6)
876 db_table
= 'group_members'
877 unique_together
= (('asso', 'uid'),)
880 return "%s to %s" %
(self
.account
.hruid
, self
.asso
.name
)
883 @python_2_unicode_compatible
884 class GroupMemberSubRequest(models
.Model
):
885 asso
= models
.ForeignKey(Group
)
886 account
= models
.ForeignKey(Account
, db_column
='uid')
887 ts
= models
.DateTimeField()
888 reason
= models
.TextField(blank
=True)
891 db_table
= 'group_member_sub_requests'
892 unique_together
= (('asso', 'uid'),)
895 return "%s to %s" %
(self
.account
.hruid
, self
.asso
.name
)
898 @python_2_unicode_compatible
899 class GroupFormerMember(models
.Model
):
900 asso
= models
.ForeignKey(Group
)
901 account
= models
.ForeignKey(Account
, db_column
='uid')
902 remember
= models
.IntegerField()
903 unsubsciption_date
= models
.DateField()
906 db_table
= 'group_former_members'
907 unique_together
= (('asso', 'uid'),)
910 return "%s to %s" %
(self
.account
.hruid
, self
.asso
.name
)
917 @python_2_unicode_compatible
918 class GroupAnnounce(models
.Model
):
919 id = models
.IntegerField(primary_key
=True)
920 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
921 asso
= models
.ForeignKey(Group
)
922 create_date
= models
.DateTimeField()
923 titre
= models
.CharField(max_length
=765)
924 texte
= models
.TextField()
925 contacts
= models
.TextField()
926 expiration
= models
.DateField()
927 promo_min
= models
.IntegerField()
928 promo_max
= models
.IntegerField()
929 flags
= models
.CharField(max_length
=36)
930 post_id
= models
.IntegerField(null
=True, blank
=True,
931 help_text
="NNTP post ID")
934 db_table
= 'group_announces'
937 return "%s: %s" %
(self
.asso
.name
, self
.titre
)
940 @python_2_unicode_compatible
941 class GroupAnnouncePhoto(models
.Model
):
942 eid
= models
.ForeignKey(GroupAnnounce
, primary_key
=True, db_column
='eid')
943 attachmime
= models
.CharField(max_length
=12)
944 attach
= models
.TextField()
945 x
= models
.IntegerField()
946 y
= models
.IntegerField()
949 db_table
= 'group_announces_photo'
952 return "%s (%s, %d x %d)" %
(self
.eid
, self
.attachmime
, self
.x
, self
.y
)
955 @python_2_unicode_compatible
956 class GroupAnnounceRead(models
.Model
):
957 announce
= models
.ForeignKey(GroupAnnounce
)
958 account
= models
.ForeignKey(Account
, db_column
='uid')
961 db_table
= 'group_announces_read'
962 unique_together
= (('announce', 'uid'),)
965 return "%s: %s" %
(self
.account
.hruid
, self
.announce_id
)
972 @python_2_unicode_compatible
973 class GroupEvent(models
.Model
):
974 eid
= models
.IntegerField(primary_key
=True)
975 asso
= models
.ForeignKey(Group
, null
=True, blank
=True)
976 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
977 intitule
= models
.CharField(max_length
=300)
978 short_name
= models
.CharField(max_length
=90)
979 paiement
= models
.ForeignKey(Payment
, null
=True, blank
=True)
980 descriptif
= models
.TextField()
981 debut
= models
.DateTimeField()
982 fin
= models
.DateTimeField(null
=True, blank
=True)
983 show_participants
= models
.BooleanField()
984 deadline_inscription
= models
.DateField(null
=True, blank
=True)
985 noinvite
= models
.IntegerField()
986 accept_nonmembre
= models
.BooleanField()
987 archive
= models
.BooleanField()
988 subscription_notification
= models
.CharField(max_length
=24)
991 db_table
= 'group_events'
994 return "%s: %s" %
(self
.asso
.name
, self
.intitule
)
997 @python_2_unicode_compatible
998 class GroupEventItem(models
.Model
):
999 event
= models
.ForeignKey(GroupEvent
, db_column
='eid')
1000 item_id
= models
.IntegerField()
1001 titre
= models
.CharField(max_length
=300)
1002 details
= models
.TextField()
1003 montant
= models
.DecimalField(max_digits
=12, decimal_places
=2)
1006 db_table
= 'group_event_items'
1007 unique_together
= (('eid', 'item_id'),)
1010 return "%s - %s" %
(self
.event
, self
.item_id
)
1013 @python_2_unicode_compatible
1014 class GroupEventParticipant(models
.Model
):
1015 event
= models
.ForeignKey(GroupEvent
, db_column
='eid')
1016 account
= models
.ForeignKey(Account
, db_column
='uid')
1017 nb
= models
.IntegerField()
1018 flags
= models
.CharField(max_length
=14)
1019 paid
= models
.FloatField()
1023 db_table
= 'group_event_participants'
1024 unique_together
= (('eid', 'uid', 'item_id'),)
1027 return "%s to %s" %
(self
.account
.hruid
, self
.item
)
1034 @python_2_unicode_compatible
1035 class GroupAuth(models
.Model
):
1036 id = models
.IntegerField(primary_key
=True)
1037 privkey
= models
.CharField(max_length
=120, unique
=True)
1038 name
= models
.CharField(max_length
=96)
1039 datafields
= models
.CharField(max_length
=765)
1040 returnurls
= models
.CharField(max_length
=765)
1041 last_used
= models
.DateField(null
=True, blank
=True)
1042 group
= models
.ForeignKey(Group
, null
=True, blank
=True)
1043 flags
= models
.CharField(max_length
=63, blank
=True)
1046 db_table
= 'group_auth'
1056 @python_2_unicode_compatible
1057 class IpWatch(models
.Model
):
1058 state
= models
.CharField(max_length
=27)
1059 detection
= models
.DateField(null
=True, blank
=True)
1060 last
= models
.DateTimeField()
1061 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
1062 description
= models
.TextField()
1063 ip
= models
.IntegerField(primary_key
=True)
1064 mask
= models
.IntegerField()
1067 db_table
= 'ip_watch'
1073 @python_2_unicode_compatible
1074 class LogAction(models
.Model
):
1075 id = models
.IntegerField(primary_key
=True)
1076 text
= models
.CharField(max_length
=96)
1077 description
= models
.CharField(max_length
=765)
1080 db_table
= 'log_actions'
1086 @python_2_unicode_compatible
1087 class LogSession(models
.Model
):
1088 id = models
.IntegerField(primary_key
=True)
1089 auth
= models
.CharField(max_length
=18)
1090 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True, related_name
='sessions')
1091 start
= models
.DateTimeField()
1092 host
= models
.CharField(max_length
=384)
1093 sauth
= models
.CharField(max_length
=18)
1094 suid
= models
.ForeignKey(Account
, null
=True, db_column
='suid', blank
=True, related_name
='su_sessions')
1095 browser
= models
.CharField(max_length
=765)
1096 forward_host
= models
.CharField(max_length
=384, blank
=True)
1097 flags
= models
.CharField(max_length
=15)
1098 ip
= models
.IntegerField()
1099 forward_ip
= models
.IntegerField(null
=True, blank
=True)
1102 db_table
= 'log_sessions'
1105 return "%s: %s@%s" %
(self
.id, self
.account
.hruid
, self
.host
)
1108 @python_2_unicode_compatible
1109 class LogLastSession(models
.Model
):
1110 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid')
1111 id = models
.ForeignKey(LogSession
, db_column
='id')
1114 db_table
= 'log_last_sessions'
1117 return self
.account
.hruid
1120 @python_2_unicode_compatible
1121 class LogEvent(models
.Model
):
1122 stamp
= models
.DateTimeField(primary_key
=True)
1123 session
= models
.ForeignKey(LogSession
, db_column
='session')
1124 action
= models
.ForeignKey(LogAction
, db_column
='action')
1125 data
= models
.TextField(blank
=True)
1128 db_table
= 'log_events'
1131 return "%s@%s: %s" %
(self
.session_id
, self
.stamp
, self
.action
.text
)
1138 @python_2_unicode_compatible
1139 class Newsletter(models
.Model
):
1140 id = models
.IntegerField(primary_key
=True)
1141 group
= models
.ForeignKey(Group
, unique
=True)
1142 name
= models
.CharField(max_length
=765)
1143 criteria
= models
.CharField(max_length
=42, blank
=True)
1146 db_table
= 'newsletters'
1152 @python_2_unicode_compatible
1153 class NewsletterIssue(models
.Model
):
1154 nlid
= models
.ForeignKey(Newsletter
, unique
=True, db_column
='nlid')
1155 id = models
.IntegerField(primary_key
=True)
1156 date
= models
.DateField()
1157 send_before
= models
.DateTimeField(null
=True, blank
=True)
1158 state
= models
.CharField(max_length
=21)
1159 sufb_json
= models
.TextField(blank
=True)
1160 title
= models
.CharField(max_length
=765)
1161 head
= models
.TextField()
1162 signature
= models
.TextField()
1163 short_name
= models
.CharField(max_length
=48, unique
=True, blank
=True)
1164 mail_title
= models
.CharField(max_length
=765)
1165 unsubscribe
= models
.IntegerField()
1166 reply_to
= models
.CharField(max_length
=765)
1169 db_table
= 'newsletter_issues'
1175 @python_2_unicode_compatible
1176 class NewsletterCat(models
.Model
):
1177 cid
= models
.AutoField(primary_key
=True)
1178 nlid
= models
.ForeignKey(Newsletter
, db_column
='nlid')
1179 pos
= models
.IntegerField()
1180 title
= models
.CharField(max_length
=384)
1183 db_table
= 'newsletter_cat'
1189 @python_2_unicode_compatible
1190 class NewsletterArt(models
.Model
):
1191 issue
= models
.ForeignKey(NewsletterIssue
, db_column
='id')
1192 aid
= models
.IntegerField()
1193 cid
= models
.ForeignKey(NewsletterCat
, null
=True, db_column
='cid', blank
=True)
1194 pos
= models
.IntegerField()
1195 title
= models
.TextField()
1196 body
= models
.TextField()
1197 append
= models
.TextField()
1200 db_table
= 'newsletter_art'
1201 unique_together
= (('issue', 'aid'),)
1204 return "%s: %s" %
(self
.issue_id
, self
.title
)
1207 @python_2_unicode_compatible
1208 class NewsletterIns(models
.Model
):
1209 account
= models
.ForeignKey(Account
, db_column
='uid')
1210 nl
= models
.ForeignKey(Newsletter
, db_column
='nlid')
1211 last
= models
.ForeignKey(NewsletterIssue
, null
=True, db_column
='last', blank
=True)
1212 hash = models
.CharField(max_length
=96, blank
=True)
1215 db_table
= 'newsletter_ins'
1216 unique_together
= (('uid', 'nlid'),)
1219 return "%s to %s" %
(self
.account
.hruid
, self
.nl
.title
)
1226 @python_2_unicode_compatible
1227 class ProfileDisplay(models
.Model
):
1228 profile
= models
.OneToOneField(Profile
, primary_key
=True, db_column
='pid')
1229 yourself
= models
.CharField(max_length
=765)
1230 public_name
= models
.CharField(max_length
=765)
1231 private_name
= models
.CharField(max_length
=765)
1232 directory_name
= models
.CharField(max_length
=765)
1233 short_name
= models
.CharField(max_length
=765)
1234 sort_name
= models
.CharField(max_length
=765)
1235 promo
= models
.CharField(max_length
=765)
1238 db_table
= 'profile_display'
1241 return self
.profile
.hrpid
1244 @python_2_unicode_compatible
1245 class ProfilePhone(models
.Model
):
1246 LINK_ADDRESS
= 'address'
1250 LINK_GROUP
= 'group'
1252 (LINK_ADDRESS
, u
"Address"),
1254 (LINK_USER
, u
"User"),
1256 (LINK_GROUP
, u
"Group"),
1259 KIND_FIXED
= 'fixed'
1260 KIND_MOBILE
= 'mobile'
1263 (KIND_FIXED
, u
"Fixed"),
1264 (KIND_MOBILE
, u
"Mobile"),
1268 profile
= models
.ForeignKey(Profile
, db_column
='pid', related_name
='phones')
1269 link_type
= models
.CharField(max_length
=21, choices
=LINK_CHOICES
)
1270 link_id
= models
.IntegerField()
1271 tel_id
= models
.IntegerField()
1272 tel_type
= models
.CharField(max_length
=18, choices
=KIND_CHOICES
)
1273 search_tel
= models
.CharField(max_length
=75)
1274 display_tel
= models
.CharField(max_length
=90)
1275 pub
= models
.CharField(max_length
=21)
1276 comment
= models
.CharField(max_length
=240)
1279 db_table
= 'profile_phones'
1280 unique_together
= (('pid', 'link_type', 'link_id', 'tel_id'),)
1283 return "%s: %s (%s)" %
(self
.profile
.hrpid
, self
.display_tel
, self
.tel_type
)
1286 def is_address(self
):
1287 return self
.link_type
== self
.LINK_ADDRESS
1291 return self
.link_type
== self
.LINK_PRO
1294 def ax_visible(self
):
1295 return is_ax_visible(self
.pub
)
1298 @python_2_unicode_compatible
1299 class ProfilePhoto(models
.Model
):
1300 profile
= models
.OneToOneField(Profile
, primary_key
=True, db_column
='pid', related_name
='photo')
1301 attachmime
= models
.CharField(max_length
=12)
1302 attach
= models
.TextField()
1303 x
= models
.IntegerField()
1304 y
= models
.IntegerField()
1305 pub
= models
.CharField(max_length
=21)
1306 last_update
= models
.DateTimeField()
1309 db_table
= 'profile_photos'
1312 return self
.profile
.hrpid
1315 @python_2_unicode_compatible
1316 class ProfilePrivateName(models
.Model
):
1317 profile
= models
.ForeignKey(Profile
, db_column
='pid', related_name
='private_name')
1318 type = models
.CharField(max_length
=27)
1319 id = models
.IntegerField()
1320 name
= models
.CharField(max_length
=765)
1323 db_table
= 'profile_private_names'
1324 unique_together
= (('pid', 'type', 'id'),)
1327 return "%s: %s" %
(self
.profile
.hrpid
, self
.type)
1330 @python_2_unicode_compatible
1331 class ProfilePublicName(models
.Model
):
1332 profile
= models
.OneToOneField(Profile
, primary_key
=True, db_column
='pid', related_name
='public_name')
1333 lastname_initial
= models
.CharField(max_length
=765)
1334 lastname_main
= models
.CharField(max_length
=765)
1335 lastname_marital
= models
.CharField(max_length
=765)
1336 lastname_ordinary
= models
.CharField(max_length
=765)
1337 firstname_initial
= models
.CharField(max_length
=765)
1338 firstname_main
= models
.CharField(max_length
=765)
1339 firstname_ordinary
= models
.CharField(max_length
=765)
1340 pseudonym
= models
.CharField(max_length
=765)
1343 db_table
= 'profile_public_names'
1346 return self
.profile
.hrpid
1349 # Profile::addresses
1350 # ------------------
1353 @python_2_unicode_compatible
1354 class ProfileAddress(models
.Model
):
1359 KIND_GROUP
= 'group'
1362 (KIND_HOME
, u
"Home"),
1363 (KIND_HQ
, u
"Headquarters"),
1365 (KIND_GROUP
, u
"Group"),
1368 profile
= models
.ForeignKey(Profile
, db_column
='pid', related_name
='addresses')
1369 job
= models
.ForeignKey('ProfileJobEnum', db_column
='jobid', blank
=True, null
=True,
1370 related_name
='addresses')
1371 group
= models
.ForeignKey('Group', db_column
='groupid', blank
=True, null
=True)
1372 addr_type
= models
.CharField(max_length
=5, db_column
='type', choices
=KIND_CHOICES
)
1373 subid
= models
.IntegerField(db_column
='id')
1374 flags
= models
.CharField(max_length
=65, blank
=True, null
=True)
1375 text
= models
.TextField()
1376 postaltext
= models
.TextField(db_column
='postalText') # Field name made lowercase.
1377 formatted_address
= models
.TextField()
1378 types
= models
.CharField(max_length
=297)
1379 latitude
= models
.FloatField(blank
=True, null
=True)
1380 longitude
= models
.FloatField(blank
=True, null
=True)
1381 southwest_latitude
= models
.FloatField(blank
=True, null
=True)
1382 southwest_longitude
= models
.FloatField(blank
=True, null
=True)
1383 northeast_latitude
= models
.FloatField(blank
=True, null
=True)
1384 northeast_longitude
= models
.FloatField(blank
=True, null
=True)
1385 location_type
= models
.CharField(max_length
=18, blank
=True, null
=True)
1386 partial_match
= models
.IntegerField()
1387 pub
= models
.CharField(max_length
=7)
1388 comment
= models
.CharField(max_length
=255, blank
=True, null
=True)
1389 geocoding_date
= models
.DateField(blank
=True, null
=True)
1390 geocoding_calls
= models
.IntegerField()
1391 postal_code_fr
= models
.CharField(max_length
=5, blank
=True, null
=True)
1392 components
= models
.ManyToManyField('ProfileAddressComponentEnum',
1393 through
='ProfileAddressComponent', related_name
='addresses')
1396 db_table
= 'profile_addresses'
1397 unique_together
= (('pid', 'jobid', 'groupid', 'type', 'id'),)
1400 if self
.addr_type
== self
.KIND_HOME
:
1401 rel
= self
.profile
.hrpid
1402 elif self
.addr_type
== self
.KIND_HQ
:
1404 rel
= unicode(self
.job
)
1407 elif self
.addr_type
== self
.KIND_GROUP
:
1408 rel
= unicode(self
.group
)
1410 rel
= u
"%s at %s" %
(self
.profile
.hrpid
, self
.pjob
.company
)
1411 return "%s address %d for %s" %
(
1412 self
.get_addr_type_display(), self
.subid
, rel
)
1415 def ax_visible(self
):
1416 return is_ax_visible(self
.pub
)
1418 def get_components_by_type(self
):
1419 flags
= collections
.defaultdict(list)
1420 for component
in self
.components
.all():
1421 for cp_type
in component
.types
.split(','):
1422 flags
[cp_type
].append(component
)
1426 def flag_list(self
):
1427 return self
.flags
.split(',')
1429 FLAG_CURRENT
= 'current'
1431 FLAG_SECONDARY
= 'secondary'
1435 return self
.FLAG_CURRENT
in self
.flag_list
1439 return self
.FLAG_MAIL
in self
.flag_list
1442 def secondary(self
):
1443 return self
.FLAG_SECONDARY
in self
.flag_list
1447 return self
.addr_type
== self
.KIND_HOME
1451 return self
.addr_type
== self
.KIND_JOB
1454 @python_2_unicode_compatible
1455 class ProfileAddressComponentEnum(models
.Model
):
1456 id = models
.BigIntegerField(primary_key
=True)
1457 short_name
= models
.CharField(max_length
=765)
1458 long_name
= models
.CharField(max_length
=765)
1459 types
= models
.CharField(max_length
=891)
1462 db_table
= 'profile_addresses_components_enum'
1465 return '%s (%s)' %
(self
.short_name
, self
.types
)
1468 @python_2_unicode_compatible
1469 class ProfileAddressComponent(models
.Model
):
1470 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1471 job
= models
.ForeignKey('ProfileJobEnum', db_column
='jobid')
1472 group
= models
.ForeignKey(Group
, db_column
='groupid', blank
=True, null
=True)
1473 addr_type
= models
.CharField(max_length
=15, db_column
='type')
1474 subid
= models
.IntegerField(db_column
='id')
1476 component
= models
.ForeignKey(ProfileAddressComponentEnum
, related_name
='component_links')
1477 address
= models
.ForeignKey(ProfileAddress
, related_name
='component_links')
1480 db_table
= 'profile_addresses_components'
1481 unique_together
= (('pid', 'jobid', 'groupid', 'type', 'id'),)
1484 return "%s (%s) for %s" %
(
1485 self
.component
.long_name
,
1486 self
.component
.types
,
1491 # Profile::networking
1492 # -------------------
1495 class ProfileBinetEnum(models
.Model
):
1496 id = models
.IntegerField(primary_key
=True)
1497 text
= models
.CharField(max_length
=150)
1498 url
= models
.CharField(max_length
=765)
1501 db_table
= 'profile_binet_enum'
1504 class ProfileBinet(models
.Model
):
1505 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1506 binet
= models
.ForeignKey(ProfileBinetEnum
)
1509 db_table
= 'profile_binets'
1510 unique_together
= (('pid', 'binet'),)
1513 class ProfileHobby(models
.Model
):
1514 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1515 id = models
.IntegerField()
1516 type = models
.CharField(max_length
=18)
1517 text
= models
.CharField(max_length
=765)
1518 pub
= models
.CharField(max_length
=21)
1521 db_table
= 'profile_hobby'
1522 unique_together
= (('pid', 'id'),)
1525 class ProfileNetworkingEnum(models
.Model
):
1526 nwid
= models
.IntegerField(primary_key
=True)
1527 name
= models
.CharField(max_length
=90)
1528 icon
= models
.CharField(max_length
=150)
1529 filter = models
.CharField(max_length
=18)
1530 network_type
= models
.CharField(max_length
=18)
1531 link
= models
.CharField(max_length
=765)
1534 db_table
= 'profile_networking_enum'
1537 class ProfileNetworking(models
.Model
):
1538 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1539 id = models
.IntegerField()
1540 nwid
= models
.ForeignKey(ProfileNetworkingEnum
, db_column
='nwid')
1541 address
= models
.CharField(max_length
=765)
1542 pub
= models
.CharField(max_length
=21)
1545 db_table
= 'profile_networking'
1546 unique_together
= (('pid', 'nwid'),)
1553 @python_2_unicode_compatible
1554 class ProfileCorpsEnum(models
.Model
):
1555 id = models
.IntegerField(primary_key
=True)
1556 name
= models
.CharField(max_length
=255, unique
=True)
1557 abbreviation
= models
.CharField(max_length
=15, unique
=True)
1558 still_exists
= models
.IntegerField()
1561 db_table
= 'profile_corps_enum'
1567 @python_2_unicode_compatible
1568 class ProfileCorpsRankEnum(models
.Model
):
1569 id = models
.IntegerField(primary_key
=True)
1570 name
= models
.CharField(max_length
=255, unique
=True)
1571 abbreviation
= models
.CharField(max_length
=15, unique
=True)
1574 db_table
= 'profile_corps_rank_enum'
1580 @python_2_unicode_compatible
1581 class ProfileCorps(models
.Model
):
1582 profile
= models
.OneToOneField(Profile
, primary_key
=True, db_column
='pid')
1583 original
= models
.ForeignKey(ProfileCorpsEnum
, db_column
='original_corpsid', related_name
='original_members')
1584 current
= models
.ForeignKey(ProfileCorpsEnum
, db_column
='current_corpsid', related_name
='current_members')
1585 rank
= models
.ForeignKey(ProfileCorpsRankEnum
, db_column
='rankid')
1586 # Ignored: corps is public information anyway.
1587 corps_pub
= models
.CharField(max_length
=21)
1590 db_table
= 'profile_corps'
1593 return "%s: %s" %
(self
.profile
.hrpid
, self
.current
.name
)
1600 @python_2_unicode_compatible
1601 class ProfileEducationEnum(models
.Model
):
1602 id = models
.IntegerField(primary_key
=True)
1603 name
= models
.CharField(max_length
=255, unique
=True, blank
=True)
1604 abbreviation
= models
.CharField(max_length
=765)
1605 url
= models
.CharField(max_length
=765, blank
=True)
1606 country
= models
.ForeignKey(GeolocCountry
, null
=True, db_column
='country', blank
=True)
1609 db_table
= 'profile_education_enum'
1616 return self
.abbreviation
or self
.name
1619 @python_2_unicode_compatible
1620 class ProfileEducationDegreeEnum(models
.Model
):
1621 id = models
.IntegerField(primary_key
=True)
1622 degree
= models
.CharField(max_length
=255, unique
=True, blank
=True)
1623 abbreviation
= models
.CharField(max_length
=765)
1624 level
= models
.IntegerField()
1627 db_table
= 'profile_education_degree_enum'
1633 @python_2_unicode_compatible
1634 class ProfileEducationFieldEnum(models
.Model
):
1635 id = models
.IntegerField(primary_key
=True)
1636 field
= models
.CharField(max_length
=255, unique
=True, blank
=True)
1639 db_table
= 'profile_education_field_enum'
1645 @python_2_unicode_compatible
1646 class ProfileEducation(models
.Model
):
1647 id = models
.IntegerField()
1648 profile
= models
.ForeignKey(Profile
, db_column
='pid', related_name
='educations')
1649 school
= models
.ForeignKey(ProfileEducationEnum
, null
=True, db_column
='eduid', blank
=True)
1650 degree
= models
.ForeignKey(ProfileEducationDegreeEnum
, null
=True, db_column
='degreeid', blank
=True)
1651 field
= models
.ForeignKey(ProfileEducationFieldEnum
, null
=True, db_column
='fieldid', blank
=True)
1652 entry_year
= models
.IntegerField(null
=True, blank
=True)
1653 grad_year
= models
.IntegerField(null
=True, blank
=True)
1654 promo_year
= models
.IntegerField(null
=True, blank
=True)
1655 program
= models
.CharField(max_length
=765, blank
=True)
1656 flags
= models
.CharField(max_length
=81)
1659 db_table
= 'profile_education'
1660 unique_together
= (('id', 'pid'),)
1663 return "%s: %s" %
(self
.profile
.hrpid
, self
.edu
.name
)
1666 @python_2_unicode_compatible
1667 class ProfileEducationDegree(models
.Model
):
1668 edu
= models
.ForeignKey(ProfileEducationEnum
, db_column
='eduid')
1669 degree
= models
.ForeignKey(ProfileEducationDegreeEnum
, db_column
='degreeid')
1672 db_table
= 'profile_education_degree'
1673 unique_together
= (('eduid', 'degreeid'),)
1676 return "%s - %s" %
(self
.edu
, self
.degree
)
1683 @python_2_unicode_compatible
1684 class ProfileJobEnum(models
.Model
):
1685 id = models
.IntegerField(primary_key
=True)
1686 name
= models
.CharField(max_length
=255, unique
=True)
1687 acronym
= models
.CharField(max_length
=765, blank
=True)
1688 url
= models
.CharField(max_length
=765, blank
=True)
1689 email
= models
.CharField(max_length
=765, blank
=True)
1690 holding
= models
.ForeignKey('self', null
=True, db_column
='holdingid', blank
=True)
1691 naf_code
= models
.CharField(max_length
=15, db_column
='NAF_code', blank
=True) # Field name made lowercase.
1692 ax_code
= models
.BigIntegerField(null
=True, db_column
='AX_code', blank
=True) # Field name made lowercase.
1693 siren_code
= models
.CharField(max_length
=9, null
=True, db_column
='SIREN_code', blank
=True) # Field name made lowercase.
1696 db_table
= 'profile_job_enum'
1703 if not hasattr(self
, '_address'):
1705 self
._address
= None
1706 for address
in self
.addresses
.all():
1707 if address
.addr_type
== address
.KIND_HQ
:
1708 self
._address
= address
1710 return self
._address
1713 @python_2_unicode_compatible
1714 class ProfileJob(models
.Model
):
1715 id = models
.IntegerField()
1716 profile
= models
.ForeignKey(Profile
, db_column
='pid', related_name
='jobs')
1717 company
= models
.ForeignKey(ProfileJobEnum
, null
=True, db_column
='jobid', blank
=True)
1718 description
= models
.CharField(max_length
=765)
1719 url
= models
.CharField(max_length
=765)
1720 email
= models
.CharField(max_length
=765)
1721 pub
= models
.CharField(max_length
=21)
1722 email_pub
= models
.CharField(max_length
=21)
1723 entry_year
= models
.CharField(max_length
=12, blank
=True)
1726 db_table
= 'profile_job'
1727 unique_together
= (('pid', 'id'),)
1730 def ax_visible(self
):
1731 return is_ax_visible(self
.pub
)
1734 def ax_visible_email(self
):
1735 return is_ax_visible(self
.email_pub
)
1738 return "%s at %s" %
(self
.profile
.hrpid
, self
.company
.name
if self
.company
else '<NONE>')
1741 # Profile::job::terms
1742 # -------------------
1745 @python_2_unicode_compatible
1746 class ProfileJobTermEnum(models
.Model
):
1747 jtid
= models
.AutoField(primary_key
=True)
1748 name
= models
.CharField(max_length
=765)
1749 full_name
= models
.CharField(max_length
=765)
1752 db_table
= 'profile_job_term_enum'
1758 @python_2_unicode_compatible
1759 class ProfileJobTermRelation(models
.Model
):
1760 jtid_1
= models
.ForeignKey(ProfileJobTermEnum
, db_column
='jtid_1', related_name
='relations_from')
1761 jtid_2
= models
.ForeignKey(ProfileJobTermEnum
, db_column
='jtid_2', related_name
='relations_to')
1762 rel
= models
.CharField(max_length
=24)
1763 computed
= models
.CharField(max_length
=24)
1766 db_table
= 'profile_job_term_relation'
1767 unique_together
= (('jtid_1', 'jtid_2', 'computed'),)
1770 return "%s <-> %s" %
(self
.jtid_1
.name
, self
.jtid_2
.name
)
1773 @python_2_unicode_compatible
1774 class ProfileJobTermSearch(models
.Model
):
1775 search
= models
.CharField(max_length
=150)
1776 job_term
= models
.ForeignKey(ProfileJobTermEnum
, db_column
='jtid')
1779 db_table
= 'profile_job_term_search'
1780 unique_together
= (('search', 'job_term'),)
1783 return "%s => %s" %
(self
.search
, self
.job_term
.name
)
1786 @python_2_unicode_compatible
1787 class ProfileJobTerm(models
.Model
):
1788 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1789 company
= models
.ForeignKey(ProfileJobEnum
, db_column
='jid')
1790 job_term
= models
.ForeignKey(ProfileJobTermEnum
, db_column
='jtid')
1791 computed
= models
.CharField(max_length
=24)
1794 db_table
= 'profile_job_term'
1795 unique_together
= (('pid', 'jid', 'jtid'),)
1798 return "%s at %s: %s" %
(self
.profile
.hrpid
, self
.company
.name
, self
.job_term
.name
)
1801 @python_2_unicode_compatible
1802 class ProfileJobEntrepriseTerm(models
.Model
):
1803 job
= models
.ForeignKey(ProfileJobEnum
, db_column
='eid')
1804 job_term
= models
.ForeignKey(ProfileJobTermEnum
, db_column
='jtid')
1807 db_table
= 'profile_job_entreprise_term'
1808 unique_together
= (('eid', 'jtid'),)
1811 return "%s: %s" %
(self
.job
.name
, self
.job_term
.name
)
1818 @python_2_unicode_compatible
1819 class ProfileLangSkillEnum(models
.Model
):
1820 iso_639_2b
= models
.CharField(max_length
=9, primary_key
=True)
1821 language
= models
.CharField(max_length
=765)
1822 language_en
= models
.CharField(max_length
=765)
1823 iso_639_2t
= models
.CharField(max_length
=9)
1824 iso_639_1
= models
.CharField(max_length
=6, blank
=True)
1827 db_table
= 'profile_langskill_enum'
1830 return self
.iso_639_2b
1833 @python_2_unicode_compatible
1834 class ProfileLangSkill(models
.Model
):
1835 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1836 lang
= models
.ForeignKey(ProfileLangSkillEnum
, db_column
='lid')
1837 level
= models
.IntegerField(null
=True, blank
=True)
1840 db_table
= 'profile_langskills'
1841 unique_together
= (('pid', 'lid'),)
1844 return "%s: %s" %
(self
.profile
.hrpid
, self
.lang
.iso_639_2b
)
1847 @python_2_unicode_compatible
1848 class ProfileSkillEnum(models
.Model
):
1849 id = models
.CharField(max_length
=9, primary_key
=True)
1850 text_fr
= models
.CharField(max_length
=330)
1851 text_en
= models
.CharField(max_length
=330)
1852 flags
= models
.CharField(max_length
=15)
1853 axfreetext
= models
.TextField()
1856 db_table
= 'profile_skill_enum'
1862 @python_2_unicode_compatible
1863 class ProfileSkill(models
.Model
):
1864 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1865 skill
= models
.ForeignKey(ProfileSkillEnum
, db_column
='cid')
1866 level
= models
.CharField(max_length
=54)
1869 db_table
= 'profile_skills'
1870 unique_together
= (('pid', 'cid'),)
1873 return "%s: %s" %
(self
.profile
.hrpid
, self
.skill
.text_en
)
1880 class ProfileMedalEnum(models
.Model
):
1881 id = models
.IntegerField(primary_key
=True)
1882 type = models
.CharField(max_length
=30)
1883 text
= models
.CharField(max_length
=765, blank
=True)
1884 img
= models
.CharField(max_length
=765, blank
=True)
1885 flags
= models
.CharField(max_length
=63)
1888 db_table
= 'profile_medal_enum'
1891 class ProfileMedalGradeEnum(models
.Model
):
1892 medal
= models
.ForeignKey(ProfileMedalEnum
, db_column
='mid')
1893 gid
= models
.IntegerField()
1894 text
= models
.CharField(max_length
=765, blank
=True)
1895 pos
= models
.IntegerField()
1898 db_table
= 'profile_medal_grade_enum'
1899 unique_together
= (('medal', 'gid'),)
1902 class ProfileMedal(models
.Model
):
1903 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1904 medal
= models
.ForeignKey(ProfileMedalEnum
)
1905 gid
= models
.IntegerField()
1906 level
= models
.CharField(max_length
=18)
1909 db_table
= 'profile_medals'
1910 unique_together
= (('pid', 'medal', 'gid'),)
1917 class ProfileMentor(models
.Model
):
1918 profile
= models
.OneToOneField(Profile
, primary_key
=True, db_column
='pid')
1919 expertise
= models
.TextField()
1922 db_table
= 'profile_mentor'
1925 class ProfileMentorCountry(models
.Model
):
1926 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1927 country
= models
.ForeignKey(GeolocCountry
, db_column
='country')
1930 db_table
= 'profile_mentor_country'
1931 unique_together
= (('pid', 'country'),)
1934 class ProfileMentorTerm(models
.Model
):
1935 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1936 job_term
= models
.ForeignKey(ProfileJobTermEnum
, db_column
='jtid')
1939 db_table
= 'profile_mentor_term'
1940 unique_together
= (('pid', 'jtid'),)
1947 class ProfilePartnersharingEnum(models
.Model
):
1948 id = models
.IntegerField(primary_key
=True)
1949 api_account
= models
.ForeignKey(Account
, null
=True, db_column
='api_uid', blank
=True)
1950 shortname
= models
.CharField(max_length
=192)
1951 name
= models
.CharField(max_length
=765)
1952 url
= models
.CharField(max_length
=765)
1953 default_sharing_level
= models
.CharField(max_length
=21, blank
=True)
1954 has_directory
= models
.IntegerField()
1955 has_bulkmail
= models
.IntegerField()
1958 db_table
= 'profile_partnersharing_enum'
1961 class ProfilePartnersharingSetting(models
.Model
):
1962 profile
= models
.ForeignKey(Profile
, db_column
='pid')
1963 partner
= models
.ForeignKey(ProfilePartnersharingEnum
)
1964 exposed_uid
= models
.CharField(max_length
=765)
1965 sharing_level
= models
.CharField(max_length
=21, blank
=True)
1966 allow_email
= models
.CharField(max_length
=18, blank
=True)
1967 last_connection
= models
.DateTimeField(null
=True, blank
=True)
1970 db_table
= 'profile_partnersharing_settings'
1971 unique_together
= (('pid', 'partner'),)
1974 class ProfilePhotoToken(models
.Model
):
1975 profile
= models
.ForeignKey(Profile
, primary_key
=True, db_column
='pid')
1976 token
= models
.CharField(max_length
=765)
1977 expires
= models
.DateTimeField()
1980 db_table
= 'profile_photo_tokens'
1987 class ProfileMergeIssue(models
.Model
):
1988 profile
= models
.ForeignKey(Profile
, primary_key
=True, db_column
='pid')
1989 issues
= models
.CharField(max_length
=144, blank
=True)
1990 entry_year_ax
= models
.IntegerField(null
=True, blank
=True)
1991 deathdate_ax
= models
.DateField(null
=True, blank
=True)
1992 name
= models
.CharField(max_length
=765, blank
=True)
1993 name_type
= models
.IntegerField(null
=True, blank
=True)
1996 db_table
= 'profile_merge_issues'
1999 class ProfileModification(models
.Model
):
2000 profile
= models
.ForeignKey(Profile
, db_column
='pid')
2001 account
= models
.ForeignKey(Account
, db_column
='uid')
2002 field
= models
.CharField(max_length
=180)
2003 oldtext
= models
.TextField(db_column
='oldText')
2004 newtext
= models
.TextField(db_column
='newText')
2005 type = models
.CharField(max_length
=33)
2006 timestamp
= models
.DateTimeField()
2009 db_table
= 'profile_modifications'
2010 unique_together
= (('pid', 'field'),)
2013 class ProfileVisibilityEnum(models
.Model
):
2014 access_level
= models
.CharField(max_length
=21, blank
=True, primary_key
=True)
2015 best_display_level
= models
.CharField(max_length
=21, blank
=True)
2016 display_levels
= models
.CharField(max_length
=72, blank
=True)
2019 db_table
= 'profile_visibility_enum'
2023 class ProfileDeltaten(models
.Model
):
2024 profile
= models
.OneToOneField(Profile
, primary_key
=True, db_column
='pid')
2025 message
= models
.TextField()
2028 db_table
= 'profile_deltaten'
2035 class ReminderType(models
.Model
):
2036 type_id
= models
.IntegerField(primary_key
=True)
2037 name
= models
.CharField(max_length
=255, unique
=True)
2038 weight
= models
.IntegerField()
2039 remind_delay_yes
= models
.IntegerField()
2040 remind_delay_no
= models
.IntegerField()
2041 remind_delay_dismiss
= models
.IntegerField()
2044 db_table
= 'reminder_type'
2047 class Reminder(models
.Model
):
2048 account
= models
.ForeignKey(Account
, db_column
='uid')
2049 type = models
.ForeignKey(ReminderType
)
2050 status
= models
.CharField(max_length
=21)
2051 remind_last
= models
.DateTimeField()
2052 remind_next
= models
.DateTimeField(null
=True, blank
=True)
2055 db_table
= 'reminder'
2056 unique_together
= (('uid', 'type'),)
2059 class ReminderTip(models
.Model
):
2060 id = models
.IntegerField(primary_key
=True)
2061 title
= models
.CharField(max_length
=192)
2062 text
= models
.TextField()
2063 priority
= models
.IntegerField()
2064 expiration
= models
.DateField()
2065 promo_min
= models
.IntegerField()
2066 promo_max
= models
.IntegerField()
2067 state
= models
.CharField(max_length
=18)
2070 db_table
= 'reminder_tips'
2077 class Survey(models
.Model
):
2078 id = models
.IntegerField(primary_key
=True)
2079 questions
= models
.TextField()
2080 title
= models
.CharField(max_length
=765)
2081 description
= models
.TextField()
2082 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
2083 end
= models
.DateField()
2084 mode
= models
.IntegerField()
2085 promos
= models
.CharField(max_length
=765)
2088 db_table
= 'surveys'
2091 class SurveyVote(models
.Model
):
2092 id = models
.IntegerField(primary_key
=True)
2093 survey
= models
.ForeignKey(Survey
)
2094 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
2097 db_table
= 'survey_votes'
2100 class SurveyAnswer(models
.Model
):
2101 id = models
.IntegerField(primary_key
=True)
2102 vote
= models
.ForeignKey(SurveyVote
)
2103 question_id
= models
.IntegerField()
2104 answer
= models
.TextField()
2107 db_table
= 'survey_answers'
2114 class GappsAccount(models
.Model
):
2115 l_userid
= models
.ForeignKey(Account
, null
=True, db_column
='l_userid', blank
=True)
2116 l_sync_password
= models
.BooleanField(default
=True)
2117 l_activate_mail_redirection
= models
.BooleanField(default
=True)
2118 g_account_id
= models
.CharField(max_length
=48, blank
=True)
2119 g_account_name
= models
.CharField(max_length
=255, primary_key
=True)
2120 g_domain
= models
.CharField(max_length
=120, blank
=True)
2121 g_first_name
= models
.CharField(max_length
=120)
2122 g_last_name
= models
.CharField(max_length
=120)
2123 g_status
= models
.CharField(max_length
=39, blank
=True)
2124 g_admin
= models
.BooleanField()
2125 g_suspension
= models
.CharField(max_length
=768, blank
=True)
2126 r_disk_usage
= models
.BigIntegerField(null
=True, blank
=True)
2127 r_creation
= models
.DateField(null
=True, blank
=True)
2128 r_last_login
= models
.DateField(null
=True, blank
=True)
2129 r_last_webmail
= models
.DateField(null
=True, blank
=True)
2132 db_table
= 'gapps_accounts'
2135 class GappsNickname(models
.Model
):
2136 l_userid
= models
.ForeignKey(Account
, null
=True, db_column
='l_userid', blank
=True)
2137 g_account_name
= models
.CharField(max_length
=768)
2138 g_nickname
= models
.CharField(max_length
=255, primary_key
=True)
2141 db_table
= 'gapps_nicknames'
2144 class GappsQueue(models
.Model
):
2145 q_id
= models
.AutoField(primary_key
=True)
2146 q_owner
= models
.ForeignKey(Account
, null
=True, blank
=True, related_name
='owned_gapps_jobs')
2147 q_recipient
= models
.ForeignKey(Account
, null
=True, blank
=True, related_name
='received_gapps_jobs')
2148 p_entry_date
= models
.DateTimeField()
2149 p_notbefore_date
= models
.DateTimeField()
2150 p_start_date
= models
.DateTimeField(null
=True, blank
=True)
2151 p_end_date
= models
.DateTimeField(null
=True, blank
=True)
2152 p_status
= models
.CharField(max_length
=24)
2153 p_priority
= models
.CharField(max_length
=27)
2154 p_admin_request
= models
.BooleanField()
2155 j_type
= models
.CharField(max_length
=30)
2156 j_parameters
= models
.TextField(blank
=True)
2157 r_softfail_date
= models
.DateTimeField(null
=True, blank
=True)
2158 r_softfail_count
= models
.IntegerField()
2159 r_result
= models
.CharField(max_length
=768, blank
=True)
2162 db_table
= 'gapps_queue'
2165 class GappsReporting(models
.Model
):
2166 date
= models
.DateField(primary_key
=True)
2167 num_accounts
= models
.IntegerField(null
=True, blank
=True)
2168 count_1_day_actives
= models
.IntegerField(null
=True, blank
=True)
2169 count_7_day_actives
= models
.IntegerField(null
=True, blank
=True)
2170 count_14_day_actives
= models
.IntegerField(null
=True, blank
=True)
2171 count_30_day_actives
= models
.IntegerField(null
=True, blank
=True)
2172 count_30_day_idle
= models
.IntegerField(null
=True, blank
=True)
2173 count_60_day_idle
= models
.IntegerField(null
=True, blank
=True)
2174 count_90_day_idle
= models
.IntegerField(null
=True, blank
=True)
2175 usage_in_bytes
= models
.BigIntegerField(null
=True, blank
=True)
2176 quota_in_mb
= models
.IntegerField(null
=True, blank
=True)
2179 db_table
= 'gapps_reporting'
2187 class Watch(models
.Model
):
2188 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid')
2189 flags
= models
.CharField(max_length
=39)
2190 actions
= models
.CharField(max_length
=105)
2191 last
= models
.DateTimeField()
2197 class WatchGroup(models
.Model
):
2198 account
= models
.ForeignKey(Account
, db_column
='uid')
2199 group
= models
.ForeignKey(Group
, db_column
='groupid')
2202 db_table
= 'watch_group'
2203 unique_together
= (('uid', 'groupid'),)
2206 class WatchNonins(models
.Model
):
2207 account
= models
.ForeignKey(Account
, db_column
='uid', related_name
='watching')
2208 watched
= models
.ForeignKey(Account
, db_column
='ni', related_name
='watched_by')
2211 db_table
= 'watch_nonins'
2212 unique_together
= (('uid', 'ni'),)
2215 class WatchProfile(models
.Model
):
2216 profile
= models
.ForeignKey(Profile
, db_column
='pid')
2217 ts
= models
.DateTimeField()
2218 field
= models
.CharField(max_length
=36)
2221 db_table
= 'watch_profile'
2222 unique_together
= (('pid', 'field'),)
2225 class WatchPromo(models
.Model
):
2226 account
= models
.ForeignKey(Account
, db_column
='uid')
2227 promo
= models
.IntegerField()
2230 db_table
= 'watch_promo'
2231 unique_together
= (('uid', 'promo'),)
2238 class MxWatch(models
.Model
):
2239 host
= models
.CharField(max_length
=192, primary_key
=True)
2240 state
= models
.CharField(max_length
=21, blank
=True)
2241 text
= models
.TextField()
2244 db_table
= 'mx_watch'
2247 class PostfixBlacklist(models
.Model
):
2248 email
= models
.CharField(max_length
=255, primary_key
=True)
2249 reject_text
= models
.CharField(max_length
=192)
2252 db_table
= 'postfix_blacklist'
2255 class PostfixMailseen(models
.Model
):
2256 crc
= models
.CharField(max_length
=24, primary_key
=True)
2257 nb
= models
.IntegerField()
2258 update_time
= models
.DateTimeField()
2259 create_time
= models
.DateTimeField()
2260 release
= models
.CharField(max_length
=18)
2263 db_table
= 'postfix_mailseen'
2266 class PostfixWhitelist(models
.Model
):
2267 email
= models
.CharField(max_length
=255, primary_key
=True)
2270 db_table
= 'postfix_whitelist'
2277 class RegisterMarketing(models
.Model
):
2278 account
= models
.ForeignKey(Account
, db_column
='uid', related_name
='received_marketings')
2279 sender
= models
.ForeignKey(Account
, null
=True, db_column
='sender', blank
=True, related_name
='sent_marketings')
2280 email
= models
.CharField(max_length
=765)
2282 date
= models
.DateField()
2283 last
= models
.DateField()
2284 nb
= models
.IntegerField()
2285 type = models
.CharField(max_length
=15, blank
=True)
2286 hash = models
.CharField(max_length
=96)
2287 message
= models
.CharField(max_length
=48)
2288 message_data
= models
.CharField(max_length
=192, blank
=True)
2289 personal_notes
= models
.TextField(blank
=True)
2292 db_table
= 'register_marketing'
2293 unique_together
= (('uid', 'email'),)
2296 class RegisterMstat(models
.Model
):
2297 account
= models
.OneToOneField(Account
, primary_key
=True, db_column
='uid', related_name
='received_marketings_stats')
2298 sender
= models
.ForeignKey(Account
, null
=True, db_column
='sender', blank
=True, related_name
='sent_marketings_stats')
2299 success
= models
.DateField()
2302 db_table
= 'register_mstats'
2305 class RegisterPending(models
.Model
):
2306 account
= models
.OneToOneField(Account
, primary_key
=True, db_column
='uid')
2307 forlife
= models
.CharField(max_length
=255, unique
=True)
2308 bestalias
= models
.CharField(max_length
=255, unique
=True)
2309 mailorg2
= models
.CharField(max_length
=765, blank
=True)
2310 password
= models
.CharField(max_length
=120)
2311 email
= models
.CharField(max_length
=765)
2312 date
= models
.DateField()
2313 relance
= models
.DateField()
2314 naissance
= models
.DateField()
2315 hash = models
.CharField(max_length
=36)
2316 services
= models
.CharField(max_length
=78)
2319 db_table
= 'register_pending'
2322 class RegisterPendingXnet(models
.Model
):
2323 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid', related_name
='pending_xnet_register')
2324 hruid
= models
.ForeignKey(Account
, unique
=True, db_column
='hruid', related_name
='pending_xnet_register_by_hruid')
2325 email
= models
.CharField(max_length
=765)
2326 date
= models
.DateField()
2327 last_date
= models
.DateField(null
=True, blank
=True)
2328 hash = models
.CharField(max_length
=36)
2329 sender_name
= models
.CharField(max_length
=765)
2330 group_name
= models
.CharField(max_length
=765)
2333 db_table
= 'register_pending_xnet'
2336 class RegisterSubs(models
.Model
):
2337 account
= models
.ForeignKey(Account
, db_column
='uid')
2338 type = models
.CharField(max_length
=15)
2339 sub
= models
.CharField(max_length
=96)
2340 domain
= models
.CharField(max_length
=192)
2343 db_table
= 'register_subs'
2344 unique_together
= (('uid', 'type', 'sub', 'domain'),)
2351 class SearchAutocomplete(models
.Model
):
2352 name
= models
.CharField(max_length
=60)
2353 query
= models
.CharField(max_length
=300)
2354 result
= models
.TextField()
2355 generated
= models
.DateTimeField()
2358 db_table
= 'search_autocomplete'
2359 unique_together
= (('name', 'query'),)
2362 class SearchName(models
.Model
):
2363 profile
= models
.ForeignKey(Profile
, db_column
='pid')
2364 token
= models
.CharField(max_length
=765)
2365 score
= models
.IntegerField()
2366 soundex
= models
.CharField(max_length
=12)
2367 flags
= models
.CharField(max_length
=18)
2368 general_type
= models
.CharField(max_length
=27)
2371 db_table
= 'search_name'
2372 unique_together
= (('pid', 'token'),)
2379 class Request(models
.Model
):
2380 account
= models
.ForeignKey(Account
, db_column
='uid')
2381 type = models
.CharField(max_length
=48)
2382 data
= models
.TextField()
2383 stamp
= models
.DateTimeField()
2384 profile
= models
.ForeignKey(Profile
, null
=True, db_column
='pid', blank
=True)
2387 db_table
= 'requests'
2388 unique_together
= (('uid', 'stamp', 'type'),)
2391 class RequestAnswer(models
.Model
):
2392 id = models
.IntegerField(primary_key
=True)
2393 category
= models
.CharField(max_length
=45)
2394 title
= models
.CharField(max_length
=150)
2395 answer
= models
.TextField()
2398 db_table
= 'requests_answers'
2401 class RequestHidden(models
.Model
):
2402 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid')
2403 hidden_requests
= models
.TextField()
2406 db_table
= 'requests_hidden'
2413 class AXLetter(models
.Model
):
2414 id = models
.IntegerField(primary_key
=True)
2415 short_name
= models
.CharField(max_length
=48, unique
=True, blank
=True)
2416 subject
= models
.CharField(max_length
=765)
2417 title
= models
.CharField(max_length
=765)
2418 body
= models
.TextField()
2419 signature
= models
.TextField()
2420 promo_min
= models
.IntegerField()
2421 promo_max
= models
.IntegerField()
2422 subset
= models
.TextField(blank
=True)
2423 subset_rm
= models
.IntegerField(null
=True, blank
=True)
2424 echeance
= models
.DateTimeField()
2425 date
= models
.DateField()
2426 bits
= models
.CharField(max_length
=48)
2429 db_table
= 'axletter'
2432 class Carva(models
.Model
):
2433 account
= models
.ForeignKey(Account
, primary_key
=True, db_column
='uid')
2434 url
= models
.CharField(max_length
=765)
2440 class Contact(models
.Model
):
2441 account
= models
.ForeignKey(Account
, db_column
='uid')
2442 contact
= models
.ForeignKey(Profile
, db_column
='contact')
2445 db_table
= 'contacts'
2446 unique_together
= (('uid', 'contact'),)
2449 class Downtime(models
.Model
):
2450 debut
= models
.DateTimeField()
2451 duree
= models
.TimeField() # This field type is a guess.
2452 resume
= models
.CharField(max_length
=765)
2453 description
= models
.TextField()
2454 services
= models
.CharField(max_length
=54)
2457 db_table
= 'downtimes'
2460 class EmailListModerate(models
.Model
):
2461 ml
= models
.CharField(max_length
=192)
2462 domain
= models
.CharField(max_length
=192)
2463 mid
= models
.IntegerField()
2464 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
2465 action
= models
.CharField(max_length
=18)
2466 ts
= models
.DateTimeField()
2467 message
= models
.TextField(blank
=True)
2468 handler
= models
.IntegerField(null
=True, blank
=True)
2471 db_table
= 'email_list_moderate'
2472 unique_together
= (('ml', 'domain', 'mid'),)
2475 class EmailSendSave(models
.Model
):
2476 account
= models
.OneToOneField(Account
, primary_key
=True, db_column
='uid')
2477 data
= models
.TextField()
2480 db_table
= 'email_send_save'
2483 class EmailWatch(models
.Model
):
2484 email
= models
.CharField(max_length
=180, primary_key
=True)
2485 state
= models
.CharField(max_length
=27)
2486 detection
= models
.DateField(null
=True, blank
=True)
2487 last
= models
.DateTimeField()
2488 account
= models
.ForeignKey(Account
, null
=True, db_column
='uid', blank
=True)
2489 description
= models
.TextField()
2492 db_table
= 'email_watch'
2495 class GeolocLanguage(models
.Model
):
2496 iso_3166_1_a2
= models
.ForeignKey(GeolocCountry
, db_column
='iso_3166_1_a2')
2497 language
= models
.CharField(max_length
=15)
2498 country
= models
.CharField(max_length
=765, blank
=True)
2499 countryplain
= models
.CharField(max_length
=765, db_column
='countryPlain', blank
=True) # Field name made lowercase.
2502 db_table
= 'geoloc_languages'
2503 unique_together
= (('iso_3166_1_a2', 'language'),)
2506 class HomonymList(models
.Model
):
2507 hrmid
= models
.CharField(max_length
=765)
2508 account
= models
.ForeignKey(Account
, db_column
='uid')
2511 db_table
= 'homonyms_list'
2512 unique_together
= (('hrmid', 'uid'),)
2515 class UrlShortener(models
.Model
):
2516 alias
= models
.CharField(max_length
=255, primary_key
=True)
2517 url
= models
.TextField()
2520 db_table
= 'url_shortener'