Project

General

Profile

« Previous | Next » 

Revision 1a43d77a

Added by Benjamin Dauvergne over 11 years ago

personnes: add a gender field, fixes #1985

View differences:

calebasse/fixtures/personnes.json
5 5
    "fields": {
6 6
      "first_name": "Gloria", 
7 7
      "last_name": "Dupond", 
8
      "display_name": "Gloria Dupond"
8
      "display_name": "Gloria Dupond",
9
      "gender": 2
9 10
    }
10 11
  }, 
11 12
  {
......
14 15
    "fields": {
15 16
      "first_name": "Fran\u00e7ois", 
16 17
      "last_name": "Durant", 
17
      "display_name": "Fran\u00e7ois Durant"
18
      "display_name": "Fran\u00e7ois Durant",
19
      "gender": 1
18 20
    }
19 21
  }, 
20 22
  {
......
23 25
    "fields": {
24 26
      "first_name": "St\u00e9phanie", 
25 27
      "last_name": "Maurier", 
26
      "display_name": "St\u00e9phanie Maurier"
28
      "display_name": "St\u00e9phanie Maurier",
29
      "gender": 2
27 30
    }
28 31
  }, 
29 32
  {
......
32 35
    "fields": {
33 36
      "first_name": "Marcus", 
34 37
      "last_name": "Hosseini", 
35
      "display_name": "Marcus Hosseini"
38
      "display_name": "Marcus Hosseini",
39
      "gender": 1
36 40
    }
37 41
  }, 
38 42
  {
......
41 45
    "fields": {
42 46
      "first_name": "Sandy", 
43 47
      "last_name": "Kilo", 
44
      "display_name": "Sandy Kilo"
48
      "display_name": "Sandy Kilo",
49
      "gender": 2
45 50
    }
46 51
  }, 
47 52
  {
......
50 55
    "fields": {
51 56
      "first_name": "Bob", 
52 57
      "last_name": "L\u00e9ponge", 
53
      "display_name": "Bob L\u00e9ponge"
58
      "display_name": "Bob L\u00e9ponge",
59
      "gender": 1
54 60
    }
55 61
  }, 
56 62
  {
......
59 65
    "fields": {
60 66
      "first_name": "Pol", 
61 67
      "last_name": "Lepoulpe", 
62
      "display_name": "Pol Lepoulpe"
68
      "display_name": "Pol Lepoulpe",
69
      "gender": 1
63 70
    }
64 71
  }, 
65 72
  {
......
68 75
    "fields": {
69 76
      "first_name": "John", 
70 77
      "last_name": "Doe", 
71
      "display_name": "John Doe"
78
      "display_name": "John Doe",
79
      "gender": 1
72 80
    }
73 81
  }, 
74 82
  {
......
77 85
    "fields": {
78 86
      "first_name": "Jack", 
79 87
      "last_name": "Itchan", 
80
      "display_name": "Jack Itchan"
88
      "display_name": "Jack Itchan",
89
      "gender": 1
81 90
    }
82 91
  }, 
83 92
  {
calebasse/personnes/forms.py
105 105
        required=False)
106 106

  
107 107
class WorkerIdForm(forms.ModelForm):
108
    sex = forms.CharField(label='Genre')
109

  
110 108
    class Meta:
111 109
        model = Worker
112
        fields = ('last_name', 'first_name', 'sex')
110
        fields = ('last_name', 'first_name', 'gender')
113 111

  
114 112
class WorkerServiceForm(forms.ModelForm):
115 113
    class Meta:
calebasse/personnes/models.py
14 14

  
15 15
from interval import Interval
16 16

  
17
from model_utils import Choices
17 18
from model_utils.managers import PassThroughManager
18 19

  
19 20
class People(BaseModelMixin, models.Model):
21
    GENDERS = Choices('', 'homme', 'femme')
20 22
    last_name = models.CharField(max_length=128, verbose_name=u'Nom')
21 23
    first_name = models.CharField(max_length=128, verbose_name=u'Prénom(s)')
22 24
    display_name = models.CharField(max_length=256,
23 25
            verbose_name=u'Nom complet', editable=False)
26
    gender = models.IntegerField(verbose_name=u"Genre", choices=GENDERS,
27
            max_length=2, default=0)
24 28

  
25 29
    def save(self, **kwargs):
26 30
        self.display_name = self.first_name + ' ' + self.last_name

Also available in: Unified diff