Esempio n. 1
0
def objects():

    from lino.modlib.outbox.models import RecipientType
    Person = resolve_model("contacts.Person")
    Company = resolve_model("contacts.Company")

    User = resolve_model(settings.SITE.user_model)
    root = User.objects.get(username='******')

    mail = Instantiator('outbox.Mail').build
    recipient_to = Instantiator(
        'outbox.Recipient', type=RecipientType.to).build

    for p in Person.objects.filter(email=''):
        try:
            p.first_name.encode('ascii')
            p.email = p.first_name.lower() + "@example.com"
            p.save()
        except UnicodeError:
            pass

    for person in Person.objects.exclude(email=''):
    #~ for person in Person.objects.filter(email__isnull=False):
        m = mail(user=root, subject='Welcome %s!' % person.first_name)
        yield m
        yield recipient_to(mail=m, partner=person)
Esempio n. 2
0
File: demo.py Progetto: raffas/lino
def objects():

    # Role = resolve_model('households.Role')
    # Member = resolve_model('households.Member')
    # Household = resolve_model('households.Household')
    Person = resolve_model('contacts.Person')
    Type = resolve_model('households.Type')

    MEN = Cycler(Person.objects.filter(gender=dd.Genders.male)
                 .order_by('-id'))
    WOMEN = Cycler(Person.objects.filter(gender=dd.Genders.female)
                   .order_by('-id'))
    TYPES = Cycler(Type.objects.all())

    ses = dd.login()
    for i in range(5):
        pv = dict(
            head=MEN.pop(), partner=WOMEN.pop(),
            type=TYPES.pop())
        ses.run(
            Person.create_household,
            action_param_values=pv)
        # yield ses.response['data_record']
        # he = MEN.pop()
        # she = WOMEN.pop()
        
        # fam = Household(name=he.last_name + "-" + she.last_name, type_id=3)
        # yield fam
        # yield Member(household=fam, person=he, role=Role.objects.get(pk=1))
        # yield Member(household=fam, person=she, role=Role.objects.get(pk=2))

    return []
Esempio n. 3
0
def objects():
    #~ dblogger.info("Installing contacts demo fixture") # use --verbosity=2
    User = resolve_model(settings.SITE.user_model)
    Company = resolve_model("contacts.Company")
    Session = resolve_model('tickets.Session')
    #~ u = User.objects.get(username='******')
    u = User.objects.all()[0]
    
    rumma = Company.objects.get(name=u'Rumma & Ko OÜ')
    
    project = Instantiator('tickets.Project',"name",user=u).build
    yield project("TIM")
    lino = project("Lino")
    yield lino
    presto = project("Presto",parent=lino)
    yield presto 
    cbss = project("CBSS connection",parent=lino)
    yield cbss 
    
    milestone = Instantiator('tickets.Milestone',"label reached",project=lino).build
    yield milestone('1.4.3',i2d(20120328))
    yield milestone('1.4.5',i2d(20120716))
    yield milestone('1.4.7',i2d(20120717))
    yield milestone('1.4.8',i2d(20120722))
    yield milestone('1.4.9',None)
    
    ticket = Instantiator('tickets.Ticket',"summary",user=u,project=presto,partner=rumma).build
    presto_proto = ticket(summary="write a first prototype",project=presto)
    yield presto_proto

    #~ session = Instantiator('tickets.Session',"description",user=u,ticket=t).build
    yield Session(date=i2d(20111113),
        user=u,ticket=presto_proto,start_time='21:45',end_time='23:28',
        description="""\
Created new module (tested in `lino_local.luc`).
Tried first with EventsByTicket instead of Comments,
but Comments are not usually planned.""")
    yield Session(date=i2d(20120603),
        user=u,ticket=presto_proto,start_time='21:45',end_time='23:28',
        description="""\
replaced Comment by Session.
""")

    yield Session(date=i2d(20120604),
        user=u,ticket=presto_proto,start_time='08:10',end_time='10:30',
        description="""\
labels, titles, tidy up, EntriesBySession.
""")

    yield Session(date=i2d(20120629),
        user=u,ticket=presto_proto,start_time='00:05',end_time='01:15',
        description="""\
ProjectsByPartner
""")

    yield Session(date=i2d(20120727),
        user=u,ticket=presto_proto,start_time='02:30',end_time='03:15',
        description="""\
TicketsByPartner
""")
Esempio n. 4
0
def objects():
    #~ User = settings.SITE.user_model()
    User = resolve_model(settings.SITE.user_model)
    Note = resolve_model('notes.Note')
    NoteType = resolve_model('notes.NoteType')

    USERS = Cycler(User.objects.all())
    if settings.SITE.project_model is not None:
        Project = resolve_model(settings.SITE.project_model)
        qs = Project.objects.all()
        if qs.count() > 10:
            qs = qs[:10]
        PROJECTS = Cycler(qs)
        #~ PROJECTS = Cycler(Project.objects.filter(name__startswith="A"))
        #~ PROJECTS = Cycler(Project.objects.all())
    #~ COMPANIES = Cycler(Company.objects.all())
    NTYPES = Cycler(NoteType.objects.all())

    #~ u = User.objects.get(username='******')

    notetype = Instantiator('notes.NoteType').build
    tel = notetype(name="phone report", build_method='appyodt')
    yield tel
    yield notetype(name="todo")

    for i in range(100):
        kw = dict(user=USERS.pop(),
                  date=settings.SITE.demo_date(days=i),
                  subject="Important note %d" % i,
                  #~ company=COMPANIES.pop(),
                  type=NTYPES.pop())
        if settings.SITE.project_model is not None:
            kw.update(project=PROJECTS.pop())
        yield Note(**kw)
Esempio n. 5
0
def objects():
  
    Person = resolve_model("contacts.Person")
    Company = resolve_model("contacts.Company")
    User = resolve_model(settings.SITE.user_model)
    
    root = User.objects.get(username='******')
    
    mail = Instantiator('mails.Mail').build
    recipient_to = Instantiator('mails.Recipient',type=RecipientType.to).build
    
    #~ for p in Person.objects.filter(email__isnull=True):
    for p in Person.objects.filter(email=''):
        try:
            p.first_name.encode('ascii')
            p.email = p.first_name.lower() + "@example.com"
            p.save()
        except UnicodeError:
            pass
            
    for person in Person.objects.exclude(email=''):
    #~ for person in Person.objects.filter(email__isnull=False):
        m = mail(sender=root,subject='Welcome %s!' % person.first_name)
        yield m
        yield recipient_to(mail=m,partner=person)
            #~ address=person.email,name=person.get_full_name(salutation=False))
    m = mail(sender=root,subject='Hello %s!' % root.first_name)
    yield m
    yield recipient_to(mail=m,partner=root)
Esempio n. 6
0
File: std.py Progetto: raffas/lino
def objects():

    #~ yield companyType('Firma','Firma')
    #~ yield companyType('asbl','asbl')
    #~ yield companyType('A.S.B.L.','A.S.B.L.')
    #~ yield companyType('sprl','sprl')
    #~ yield companyType('GmbH','GmbH')
    #~ yield companyType('AG','AG')
    #~ yield companyType('S.A.','S.A.')
    #~ yield companyType('S.C.','S.C.')
    #~ yield companyType('V.o.G.','V.o.G.')
    #~ yield companyType('G.o.E.','G.o.E.')
    #~ yield companyType('A.S.B.L.','Association sans but lucratif')
    #~ yield companyType('Maison','Maison')
    #~ yield companyType('Fachklinik','Fachklinik')
    #~ yield companyType("Centre d'Accueil d'Urgence","Centre d'Accueil d'Urgence")

    #~ yield companyType(**babel_values('name',
        #~ en=u"Public Limited Company",
        #~ nl=u'NV (Naamloze Vennootschap)',
        #~ fr=u'SA (Société Anonyme)',
        #~ de=u"AG (Aktiengesellschaft)"))

    for ct in COMPANY_TYPES:
        yield companyType(**ct)

    yield roletype(**babel_values('name', en="Manager", fr='Gérant', de="Geschäftsführer", et="Tegevjuht"))
    yield roletype(**babel_values('name', en="Director", fr='Directeur', de="Direktor", et="Direktor"))
    yield roletype(**babel_values('name', en="Secretary", fr='Secrétaire', de="Sekretär", et="Sekretär"))
    yield roletype(**babel_values('name', en="IT Manager", fr='Gérant informatique', de="EDV-Manager", et="IT manager"))
    yield roletype(**babel_values('name', en="President", fr='Président', de="Präsident", et="President"))

    if settings.SITE.is_installed('contenttypes'):

        from django.contrib.contenttypes.models import ContentType

        I = Instantiator('system.HelpText',
                         'content_type field help_text').build

        Person = resolve_model("contacts.Person")
        t = ContentType.objects.get_for_model(Person)

        #~ yield I(t,'birth_date',u"""\
    #~ Unkomplette Geburtsdaten sind erlaubt, z.B.
    #~ <ul>
    #~ <li>00.00.1980 : irgendwann in 1980</li>
    #~ <li>00.07.1980 : im Juli 1980</li>
    #~ <li>23.07.0000 : Geburtstag am 23. Juli, Alter unbekannt</li>
    #~ </ul>
    #~ """)

        Partner = resolve_model('contacts.Partner')
        t = ContentType.objects.get_for_model(Partner)
        yield I(t, 'language', u"""\
    Die Sprache, in der Dokumente ausgestellt werden sollen.
    """)
Esempio n. 7
0
def objects():
    Person = resolve_model("contacts.Person")
    Company = resolve_model("contacts.Company")
    if not isinstance(Company,UnresolvedModel):
        roletype = Instantiator('links.LinkType',
            a_type=ContentType.objects.get_for_model(Company),
            b_type=ContentType.objects.get_for_model(Person)
            ).build
        yield roletype(**babel_values('name',en="Manager",fr=u'Gérant',de=u"Geschäftsführer",et=u"Manager"))
        yield roletype(**babel_values('name',en="Director",fr=u'Directeur',de=u"Direktor",et=u"Direktor"))
        yield roletype(**babel_values('name',en="Secretary",fr=u'Sécrétaire',de=u"Sekretär",et=u"Sekretär"))
        yield roletype(**babel_values('name',en="IT Manager",fr=u'Gérant informatique',de=u"EDV-Manager",et=u"IT manager"))
Esempio n. 8
0
File: std.py Progetto: cuchac/lino
def objects():

    #~ yield organisationType('Firma','Firma')
    #~ yield organisationType('asbl','asbl')
    #~ yield organisationType('A.S.B.L.','A.S.B.L.')
    #~ yield organisationType('sprl','sprl')
    #~ yield organisationType('GmbH','GmbH')
    #~ yield organisationType('AG','AG')
    #~ yield organisationType('S.A.','S.A.')
    #~ yield organisationType('S.C.','S.C.')
    #~ yield organisationType('V.o.G.','V.o.G.')
    #~ yield organisationType('G.o.E.','G.o.E.')
    #~ yield organisationType('A.S.B.L.','Association sans but lucratif')
    #~ yield organisationType('Maison','Maison')
    #~ yield organisationType('Fachklinik','Fachklinik')
    #~ yield organisationType("Centre d'Accueil d'Urgence","Centre d'Accueil d'Urgence")

    #~ yield organisationType(**babel_values('name',
        #~ en=u"Public Limited Company",
        #~ nl=u'NV (Naamloze Vennootschap)',
        #~ fr=u'SA (Société Anonyme)',
        #~ de=u"AG (Aktiengesellschaft)"))

    for ct in COMPANY_TYPES:
        yield organisationType(**ct)

    yield roletype(**babel_values('name', en="Manager", fr=u'Gérant', de=u"Geschäftsführer", et=u"Manager"))
    yield roletype(**babel_values('name', en="Director", fr=u'Directeur', de=u"Direktor", et=u"Direktor"))
    yield roletype(**babel_values('name', en="Secretary", fr=u'Sécrétaire', de=u"Sekretär", et=u"Sekretär"))
    yield roletype(**babel_values('name', en="IT Manager", fr=u'Gérant informatique', de=u"EDV-Manager", et=u"IT manager"))

    I = Instantiator('system.HelpText', 'content_type field help_text').build

    Person = resolve_model("partners.Person")
    t = ContentType.objects.get_for_model(Person)
Esempio n. 9
0
 def migrate_from_0_0_1(globals_dict):
     """
     - Renamed `countries.City` to `countries.Place`
     """
     countries_Place = resolve_model("countries.Place")
     globals_dict.update(countries_City=countries_Place)
     return '0.0.2'
Esempio n. 10
0
 def migrate_from_0_0_1(globals_dict):
     """
     - Renamed `countries.City` to `countries.Place`
     """
     countries_Place = resolve_model("countries.Place")
     globals_dict.update(countries_City=countries_Place)
     return '0.0.2'
Esempio n. 11
0
    def test01(self):
        """
        Used on `/blog/2011/0414`.
        See the source code at :srcref:`/lino/apps/pcsw/tests/pcsw_tests.py`.
        """

        Person = resolve_model("contacts.Person")
        Company = resolve_model("contacts.Company")
        
        p1 = Person(first_name="First",last_name="Person")
        p1.save()
        p2 = Person(first_name="Second",last_name="Person")
        p2.save()
        c1 = Company(name="First Company")
        c1.save()
        
        lt = LinkType(name="Director",
            a_type=ContentType.objects.get_for_model(Company),
            b_type=ContentType.objects.get_for_model(Person))
        lt.save()
        
        link = Link(type=lt,a=c1,b=p1)
        link.save()
        
        p1s = unicode(p1)
        c1s = unicode(c1)
        
        self.assertEqual(unicode(link),
            "%s is Director of %s" % (p1s,c1s))
        
        self.assertEqual(link.a,c1)
        self.assertEqual(link.b,p1)
        
        link.b = p2
        link.save()
        self.assertEqual(link.b,p2)
        
        link = Link.objects.get(pk=1)
        
        self.assertEqual(link.b,p2)
        self.assertEqual(link.a,c1)
        
        try:
            link.a = p1
        except ValueError,e:
            self.assertEqual(str(e),
                "Expected <class 'lino.projects.pcsw.models.Company'> instance but got <Person: First PERSON (100)>")
Esempio n. 12
0
def objects():
  
    Role = resolve_model('households.Role')
    Member = resolve_model('households.Member')
    Household = resolve_model('households.Household')
    Person = resolve_model('contacts.Person')
    
    MEN = Cycler(Person.objects.filter(gender=mixins.Genders.male).order_by('birth_date'))
    WOMEN = Cycler(Person.objects.filter(gender=mixins.Genders.female).order_by('birth_date'))
    
    for i in range(3):
        he = MEN.pop()
        she = WOMEN.pop()
        #~ fam = Household(father=MEN.pop(),mother=WOMEN.pop())
        fam = Household(name=he.last_name+"-"+she.last_name,type_id=3)
        yield fam
        yield Member(household=fam,person=he,role=Role.objects.get(pk=1))
        yield Member(household=fam,person=she,role=Role.objects.get(pk=2))
Esempio n. 13
0
def objects():

    Member = rt.modules.households.Member
    MemberRoles = rt.modules.households.MemberRoles
    # Household = resolve_model('households.Household')
    Person = resolve_model(dd.apps.households.person_model)
    Type = resolve_model('households.Type')

    MEN = Cycler(Person.objects.filter(gender=dd.Genders.male)
                 .order_by('-id'))
    WOMEN = Cycler(Person.objects.filter(gender=dd.Genders.female)
                   .order_by('-id'))
    TYPES = Cycler(Type.objects.all())

    ses = rt.login()
    for i in range(5):
        pv = dict(
            head=MEN.pop(), partner=WOMEN.pop(),
            type=TYPES.pop())
        ses.run(
            Person.create_household,
            action_param_values=pv)
        # yield ses.response['data_record']
        # he = MEN.pop()
        # she = WOMEN.pop()
        
        # fam = Household(name=he.last_name + "-" + she.last_name, type_id=3)
        # yield fam
        # yield Member(household=fam, person=he, role=Role.objects.get(pk=1))
        # yield Member(household=fam, person=she, role=Role.objects.get(pk=2))

    i = 0
    for m in Member.objects.filter(role=MemberRoles.head):
        i += 1
        if i % 3 == 0:
            m.end_date = i2d(20020304)
            yield m

            pv = dict(
                head=m.person, partner=WOMEN.pop(),
                type=TYPES.pop())
            ses.run(
                Person.create_household,
                action_param_values=pv)
Esempio n. 14
0
def create_and_get(model, **kw):
    """
    Instantiate, full_clean, save 
    and read back from database (the latter to avoid certain Django side effects)
    """
    model = resolve_model(model)
    o = model(**kw)
    o.full_clean()
    o.save()
    return model.objects.get(pk=o.pk)
Esempio n. 15
0
def setup_params_choosers(self):
    if self.parameters:
        for k, fld in self.parameters.items():
            if isinstance(fld, models.ForeignKey):
                fld.rel.to = resolve_model(fld.rel.to)
                from lino.core.kernel import set_default_verbose_name
                set_default_verbose_name(fld)
                #~ if fld.verbose_name is None:
                    #~ fld.verbose_name = fld.rel.to._meta.verbose_name

            check_for_chooser(self, fld)
Esempio n. 16
0
    def class_init(cls):
        """
        Called internally a site startup. Don't override.
        """
        master = getattr(cls, 'master', None)
        if master is not None:
            cls.master = resolve_model(master)

        actions.install_layout(cls, 'detail_layout', layouts.FormLayout)
        actions.install_layout(
            cls, 'insert_layout', layouts.FormLayout,
            window_size=(cls.insert_layout_width, 'auto'))
Esempio n. 17
0
def objects():
    if settings.SITE.user_model:
        tft = Instantiator('system.TextFieldTemplate',"name description text").build
        
        yield tft("hello","Inserts 'Hello, world!'","""<div>Hello, world!</div>""")
        #~ yield tft("mfg","",'<p>Mit freundlichen Gr&uuml;&szlig;en<br><p class="data_field">root</p>')
        yield tft("mfg","",'<p>Mit freundlichen Gr&uuml;&szlig;en<br><p>{{request.subst_user or request.user}}</p>')
    
    if settings.SITE.is_installed('contenttypes'):
        HelpText = resolve_model('system.HelpText')
        HT = Instantiator(HelpText,"content_type field help_text").build
        yield HT(ContentType.objects.get_for_model(HelpText),'field',"The name of the field.")
Esempio n. 18
0
def discover():
    """
    - Each model can receive a number of "slaves". 
      Slaves are tables whose data depends on an instance 
      of another model (their master).
      
    - For each model we want to find out the "default table".
      The "choices table" for a foreignkey field is also currently 
      simply the pointed model's default table.
      :modattr:`_lino_default_table`

    """
              
    logger.debug("Analyzing Tables...")
    #~ logger.debug("20111113 Register Table actors...")
    for rpt in actors.actors_list:
        if issubclass(rpt,Table) and rpt is not Table:
            register_report(rpt)
        elif issubclass(rpt,VirtualTable) and rpt is not VirtualTable:
            register_report(rpt)
        if issubclass(rpt,frames.Frame) and rpt is not frames.Frame:
            register_frame(rpt)
            
    logger.debug("Instantiate model tables...")
    for model in models.get_models():
        """Not getattr but __dict__.get because of the mixins.Listings trick."""
        rpt = model.__dict__.get('_lino_default_table',None)
        #~ rpt = getattr(model,'_lino_default_table',None)
        #~ logger.debug('20111113 %s._lino_default_table = %s',model,rpt)
        if rpt is None:
            rpt = table_factory(model)
            register_report(rpt)
            rpt.class_init()
            #~ rpt.collect_actions()
            model._lino_default_table = rpt
            
            
    logger.debug("Analyze %d slave tables...",len(slave_reports))
    for rpt in slave_reports:
        rpt.master = resolve_model(rpt.master)
        slaves = getattr(rpt.master,"_lino_slaves",None)
        if slaves is None:
            slaves = {}
            rpt.master._lino_slaves = slaves
        slaves[rpt.actor_id] = rpt
Esempio n. 19
0
 def __init__(self, model, fieldnames=None, converter_classes={}, **kw):
     #~ self.model = resolve_model(model,strict=True)
     self.model = resolve_model(model)
     #~ if isinstance(self.model,UnresolvedModel):
         #~ logger.warning("20120818 unresolved model %s",model)
         #~ return
     if not self.is_active():
         def noop(*values, **kw):
             pass
         self.build = noop
         return
     #~ if self.model._meta.pk is None:
         #~ raise Exception("Model %r is not installed (_meta.pk is None)." % self.model)
     #~ if type(fieldnames) == str:
     if isinstance(fieldnames, basestring):
         fieldnames = fieldnames.split()
     self.default_values = kw
     #self.fieldnames = fieldnames
     lookup_fields = {}
     self.converters = []
     if fieldnames is None:
         self.fields = self.model._meta.fields
     else:
         self.fields = []
         for name in fieldnames:
             a = name.split(":")
             if len(a) == 2:
                 name = a[0]
                 lookup_fields[name] = a[1]
             field = self.model._meta.get_field(name)
             self.fields.append(field)
     # print " ".join(dir(model_class))
     # print " ".join(model_class._meta.fields)
     # for f in model_class._meta.fields:
     # for f in self.fields:
     for f in self.model._meta.fields + self.model._meta.many_to_many:
         cv = None
         cvc = converter_classes.get(f.name, None)
         if cvc is not None:
             cv = cvc(f)
         else:
             cv = make_converter(f, lookup_fields)
         if cv is not None:
             self.converters.append(cv)
Esempio n. 20
0
    def lino_resolve_type(self):
        """
        Unlike attach_to_model, this is also called on virtual 
        fields that are defined on an Actor
        """
        # ~ logger.info("20120903 lino_resolve_type %s.%s", actor_or_model, name)
        # ~ if self.name is not None:
        # ~ if self.name != name:
        # ~ raise Exception("Tried to re-use %s.%s" % (actor_or_model,name))
        # ~ self.name = name

        if isinstance(self.return_type, basestring):
            self.return_type = resolve_field(self.return_type)

        # ~ self.return_type.name = self.name
        if isinstance(self.return_type, models.ForeignKey):
            f = self.return_type
            f.rel.to = resolve_model(f.rel.to)
            if f.verbose_name is None:
                # ~ if f.name is None:
                f.verbose_name = f.rel.to._meta.verbose_name
                # ~ from lino.core.kernel import set_default_verbose_name
                # ~ set_default_verbose_name(self.return_type)

        # ~ removed 20120919 self.return_type.editable = self.editable
        for k in """to_python choices save_form_data 
          value_to_string verbose_name max_length rel
          max_digits decimal_places
          help_text
          blank""".split():
            setattr(self, k, getattr(self.return_type, k, None))
        # ~ logger.info('20120831 VirtualField %s on %s',name,actor_or_model)

        # ~ store = self.model.get_default_table().get_handle().store
        # ~ self._lino_atomizer = store.create_field(self,self.name)
        # ~ self._lino_atomizer = self.return_type._lino_atomizer
        from lino.ui import store

        # ~ self._lino_atomizer = store.create_field(self,self.name)
        store.get_atomizer(self, self.name)
Esempio n. 21
0
def objects():
  
    Role = resolve_model('households.Role')
    Type = resolve_model('households.Type')
    #~ yield Role(**babel_values('name',
          #~ de=u"Vater",
          #~ fr=u"père",
          #~ en=u"father",
          #~ ))
    #~ yield Role(**babel_values('name',
          #~ de=u"Mutter",
          #~ fr=u"mère",
          #~ en=u"mother",
          #~ ))
    #~ yield Role(**babel_values('name',
          #~ de=u"Tochter",
          #~ fr=u"fille",
          #~ en=u"daughter",
          #~ ))
    #~ yield Role(**babel_values('name',
          #~ de=u"Sohn",
          #~ fr=u"fils",
          #~ en=u"son",
          #~ ))
    
    kw = babel_values('name',
          de=u"Haushaltsvorstand",
          fr=u"Chef de ménage",
          en=u"Head of household",
          )
    yield Role(name_giving=True,**kw)
    kw = babel_values('name',
          de=u"Ehepartner",
          fr=u"Conjoint",
          en=u"Spouse",
          )
    yield Role(name_giving=True,**kw)
    kw = babel_values('name',
          de=u"Partner",
          fr=u"Partenaire",
          en=u"Partner",
          )
    yield Role(name_giving=True,**kw)
    kw = babel_values('name',
          de=u"Mitbewohner",
          fr=u"Cohabitant",
          en=u"Cohabitant",
          )
    yield Role(**kw)
    kw = babel_values('name',
          de=u"Kind",
          fr=u"Enfant",
          en=u"Child",
          )
    #~ kw.update(babel_values('male',
          #~ de=u"Sohn",
          #~ fr=u"Fils",
          #~ en=u"Son",
          #~ ))
    #~ kw.update(babel_values('female',
          #~ de=u"Tochter",
          #~ fr=u"Fille",
          #~ en=u"Daughter",
          #~ ))
    yield Role(**kw)
    
    kw = babel_values('name',
          de=u"Adoptivkind",
          fr=u"Enfant adopté",
          en=u"Adopted child",
          )
    #~ kw.update(babel_values('male',
          #~ de=u"Adoptivsohn",
          #~ fr=u"Fils adoptif",
          #~ en=u"Adopted son",
          #~ ))
    #~ kw.update(babel_values('female',
          #~ de=u"Adoptivtochter",
          #~ fr=u"Fille adoptive",
          #~ en=u"Adopted daughter",
          #~ ))
    yield Role(**kw)
    
    yield Type(**babel_values('name',
          de=u"Ehepaar",
          fr=u"Couple marié",
          en=u"Married couple",
          ))
    yield Type(**babel_values('name',
          de=u"Familie",
          fr=u"Famille",
          en=u"Family",
          ))
    yield Type(**babel_values('name',
          de=u"Faktischer Haushalt",
          fr=u"Ménage de fait",
          en=u"Factual household",
          ))
    yield Type(**babel_values('name',
          de=u"Legale Wohngemeinschaft",
          fr=u"Cohabitation légale",
          en=u"Legal cohabitation",
          ))
Esempio n. 22
0
 def attach_to_model(self,model,name):
     self.child_model = resolve_model(self.child_model,model._meta.app_label)
     VirtualField.attach_to_model(self,model,name)
Esempio n. 23
0
from django.conf import settings
from django.core.exceptions import ValidationError

from lino.utils import dbfreader
from lino.utils import dblogger
from north import dpy

from lino.modlib.accounts.utils import AccountTypes

from lino.core.dbutils import resolve_model, obj2str
from lino.core.dbutils import is_valid_email

from lino import dd

Activity = resolve_model("pcsw.Activity")
Country = resolve_model("countries.Country")
Place = resolve_model("countries.Place")
Household = resolve_model("households.Household")
Person = resolve_model("contacts.Person")
Company = resolve_model("contacts.Company")
Account = dd.resolve_model("accounts.Account")
Group = dd.resolve_model("accounts.Group")

from lino.runtime import *

if True:
    users = dd.resolve_app("users")
    tickets = dd.resolve_app("tickets")
    households = dd.resolve_app("households")
    vat = dd.resolve_app("vat")
Esempio n. 24
0
from django.conf import settings
from django.core.exceptions import ValidationError

from lino.utils import dbfreader
from lino.utils import dblogger
from north import dpy

from lino.modlib.accounts.utils import AccountTypes

from lino.core.dbutils import resolve_model, obj2str
from lino.core.dbutils import is_valid_email

from lino import dd

Activity = resolve_model('pcsw.Activity')
Country = resolve_model('countries.Country')
City = resolve_model('countries.City')
Household = resolve_model('households.Household')
Person = resolve_model("contacts.Person")
Company = resolve_model("contacts.Company")
Account = dd.resolve_model('accounts.Account')
Group = dd.resolve_model('accounts.Group')

from lino.runtime import *

if True:
    users = dd.resolve_app('users')
    tickets = dd.resolve_app('tickets')
    households = dd.resolve_app('households')
    vat = dd.resolve_app('vat')
Esempio n. 25
0
def objects():
    group = Instantiator('debts.AccountGroup').build
    g = group(account_type=AccountType.income,**babel_values('name',
          de=u"Monatliche Einkünfte",
          fr=u"Revenus mensuels",
          en=u"Monthly incomes"
          ))
    yield g
    account = Instantiator('debts.Account',group=g).build
    yield account(required_for_person=True,**babel_values('name',
          de=u"Gehälter",
          fr=u"Salaires",
          en=u"Salaries"
          ))
    yield account(required_for_person=True,**babel_values('name',
          de=u"Renten",
          fr=u"Pension",
          en=u"Pension"
          ))
    yield account(required_for_person=True,**babel_values('name',
          de=u"Integrationszulage",
          fr=u"Allocation d'intégration",
          en=u"Integration aid"
          ))

    g = group(account_type=AccountType.income,**babel_values('name',
          de=u"Jährliche Einkünfte",
          fr=u"Revenus annuels",
          en=u"Yearly incomes"
          ))
    yield g
    account = Instantiator('debts.Account',group=g).build
    yield account(required_for_person=True,**babel_values('name',
          de=u"Urlaubsgeld",
          fr=u"Congé payé",
          en=u"Paid holiday"
          ))
    yield account(required_for_person=True,**babel_values('name',
          de=u"Jahresendzulage",
          fr=u"Prime de fin d'année",
          en=u"Year-end prime"
          ))

    g = group(account_type=AccountType.expense,**babel_values('name',
          de=u"Monatliche Ausgaben",
          fr=u"Dépenses mensuelles",
          en=u"Monthly expenses"
          ))
    yield g
    account = Instantiator('debts.Account',group=g).build
    yield account(required_for_household=True,**babel_values('name',
          de=u"Miete",
          fr=u"Loyer",
          en=u"Rent"
          ))
    yield account(required_for_household=True,**babel_values('name',
          de=u"Strom",
          fr=u"Electricité",
          en=u"Electricity"
          ))


    g = group(account_type=AccountType.expense,**babel_values('name',
          de=u"Steuern",
          fr=u"Taxes",
          en=u"Taxes"
          ))
    yield g
    account = Instantiator('debts.Account',group=g,periods=12).build
    yield account(required_for_household=True,**babel_values('name',
          de=u"Müllsteuer",
          fr=u"Taxe déchets",
          en=u"Waste tax"
          ))

    g = group(account_type=AccountType.asset,**babel_values('name',
          de=u"Aktiva, Vermögen, Kapital",
          fr=u"Actifs",
          en=u"Assets"
          ))
    yield g
    account = Instantiator('debts.Account',group=g).build
    yield account(**babel_values('name',
          de=u"Vermögen",
          fr=u"Propriété",
          en=u"Assets"
          ))
    account = Instantiator('debts.Account',group=g).build
    yield account(**babel_values('name',
          de=u"Haus",
          fr=u"Maison",
          en=u"House"
          ))
    yield account(**babel_values('name',
          de=u"Auto",
          fr=u"Voiture",
          en=u"Car"
          ))
    
    
    g = group(account_type=AccountType.liability,**babel_values('name',
          de=u"Guthaben, Schulden, Verbindlichkeit",
          fr=u"Créances et dettes",
          en=u"Liabilities"
          ))
    yield g
    account = Instantiator('debts.Account',group=g).build
    yield account(**babel_values('name',
          de=u"Kredite",
          fr=u"Crédits",
          en=u"Loans"
          ))
    yield account(**babel_values('name',
          de=u"Schulden",
          fr=u"Emprunts",
          en=u"Debts"
          ))
    yield account(**babel_values('name',
          de=u"Gerichtsvollzieher",
          fr=u"Juge",
          en=u"Judge"
          ))
    yield account(**babel_values('name',
          de=u"Zahlungsrückstände",
          fr=u"Factures à payer",
          en=u"Invoices to pay"
          ))

    #~ budget = Instantiator('debts.Budget').build
    #~ from lino.modlib.users.models import User
    #~ root = User.objects.get(username='******')
    
    User = resolve_model('users.User')
    kerstin = User(username="******",
        first_name="Kerstin",last_name=u"Küpper",
        profile=UserProfiles.kerstin)
    yield kerstin
    
    
    Household = resolve_model('households.Household')
    Budget = resolve_model('debts.Budget')
    Actor = resolve_model('debts.Actor')
    for hh in Household.objects.all():
        #~ sub_budgets = []
        for p in hh.member_set.all():
            yield Budget(partner_id=p.person.id,user=kerstin)
            #~ sub_budgets.append(b)
            #~ yield b
        yield Budget(partner_id=hh.id,user=kerstin)
        #~ yield b
        #~ for sb in sub_budgets:
            #~ yield Actor(budget=b,sub_budget=sb)
        
    Budget = resolve_model('debts.Budget')
    #~ Debt = resolve_model('debts.Debt')
    Entry = resolve_model('debts.Entry')
    Account = resolve_model('debts.Account')
    Company = resolve_model('contacts.Company')
    AMOUNTS = Cycler([i*5.24 for i in range(10)])
    PARTNERS = Cycler(Company.objects.all())
    ACCOUNTS = Cycler(Account.objects.filter(type=AccountType.liability))
    for b in Budget.objects.all():
        #~ n = min(3,b.actor_set.count())
        for e in b.entry_set.all():
            #~ for i in range(n):
            e.amount = n2dec(AMOUNTS.pop())
            e.save()
        for i in range(3):
            a = int(AMOUNTS.pop()*5)
            yield Entry(budget=b,
                account=ACCOUNTS.pop(),
                partner=PARTNERS.pop(),amount=a,
                monthly_rate=n2dec(a/20))
Esempio n. 26
0
def objects():

    organisation = Instantiator(
        'partners.Organisation', "name zip_code city:name street street_no", country='EE').build
    yield organisation('Rumma & Ko OÜ', '10115', 'Tallinn', 'Tartu mnt', '71')
    #~ Organisation = resolve_model('partners.Organisation')
    #~ obj = Organisation(name='Rumma & Ko OÜ',zip_code='10115',street='Tartu mnt',street_no='71')
    #~ print obj2str(obj)
    #~ yield obj

    organisation = Instantiator(
        'partners.Organisation', "name zip_code city:name street street_no", country='BE').build
    yield organisation('Bäckerei Ausdemwald', '4700', 'Eupen',  'Vervierser Straße', '45')
    yield organisation('Bäckerei Mießen',     '4700', 'Eupen',  'Gospert', '103')
    yield organisation('Bäckerei Schmitz',    '4700', 'Eupen',  'Aachener Straße', '53')
    yield organisation('Garage Mergelsberg',  '4720', 'Kelmis', 'Kasinostraße', '13')

    organisation = Instantiator(
        'partners.Organisation', "name zip_code city:name street street_no", country='NL').build
    yield organisation('Donderweer BV', '4816 AR', 'Breda', 'Edisonstraat', '12')
    yield organisation('Van Achter NV', '4836 LG', 'Breda', 'Hazeldonk', '2')

    organisation = Instantiator(
        'partners.Organisation', "name zip_code city:name street street_no", country='DE').build
    yield organisation('Hans Flott & Co', '22453', 'Hamburg', 'Niendorfer Weg', '532')
    if 'de' in settings.SITE.languages:
        munich = 'München'
    else:
        munich = 'Munich'
    yield organisation('Bernd Brechts Bücherladen', '80333', munich, 'Brienner Straße', '18')
    yield organisation('Reinhards Baumschule', '12487 ', 'Berlin', 'Segelfliegerdamm', '123')

    organisation = Instantiator(
        'partners.Organisation', "name zip_code city:name street street_no", country='FR').build
    yield organisation('Moulin Rouge', '75018', 'Paris', 'Boulevard de Clichy', '82')
    yield organisation('Auto École Verte', '54000 ', 'Nancy', 'rue de Mon Désert', '12')

    City = resolve_model('countries.City')
    vigala = City.objects.get(name__exact='Vigala')
    #~ tallinn = City.objects.get(name__exact='Tallinn')
    person = Instantiator("partners.Person", "first_name last_name",
                          country='EE', street='Uus', street_no='1',
                          addr2='Vana-Vigala küla',
                          city=vigala, zip_code='78003').build
    yield person('Luc',  'Saffre', gender=mixins.Genders.male)

    eupen = City.objects.get(name__exact='Eupen')
    person = Instantiator("partners.Person", "first_name last_name",
                          country='BE', city=eupen, zip_code='4700').build
    yield person('Andreas',  'Arens', gender=mixins.Genders.male)
    yield person('Annette',  'Arens', gender=mixins.Genders.female)
    yield person('Hans',     'Altenberg', gender=mixins.Genders.male)
    yield person('Alfons',   'Ausdemwald', gender=mixins.Genders.male)
    yield person('Laurent',  'Bastiaensen', gender=mixins.Genders.male)
    yield person('Charlotte', 'Collard', gender=mixins.Genders.female)
    yield person('Ulrike',   'Charlier', gender=mixins.Genders.female)
    yield person('Marc',  'Chantraine', gender=mixins.Genders.male)
    yield person('Daniel',   'Dericum', gender=mixins.Genders.male)
    yield person('Dorothée', 'Demeulenaere', gender=mixins.Genders.female)
    yield person('Dorothée', 'Dobbelstein-Demeulenaere', gender=mixins.Genders.female)
    yield person('Dorothée', 'Dobbelstein', gender=mixins.Genders.female)
    yield person('Berta',    'Ernst', gender=mixins.Genders.female)
    yield person('Bernd',    'Evertz', gender=mixins.Genders.male)
    yield person('Eberhart', 'Evers', gender=mixins.Genders.male)
    yield person('Daniel',   'Emonts', gender=mixins.Genders.male)
    yield person('Edgar',    'Engels', gender=mixins.Genders.male)
    yield person('Luc',      'Faymonville', gender=mixins.Genders.male)
    yield person('Germaine', 'Gernegroß', gender=mixins.Genders.female)
    yield person('Gregory',  'Groteclaes', gender=mixins.Genders.male)
    yield person('Hildegard', 'Hilgers', gender=mixins.Genders.female)
    yield person('Henri',    'Hilgers', gender=mixins.Genders.male)
    yield person('Irene',    'Ingels', gender=mixins.Genders.female)
    yield person('Jérémy',   'Jansen', gender=mixins.Genders.male)
    yield person('Jacqueline', 'Jacobs', gender=mixins.Genders.female)
    yield person('Johann', 'Johnen', gender=mixins.Genders.male)
    yield person('Josef', 'Jonas', gender=mixins.Genders.male)
    yield person('Jan',   'Jousten', gender=mixins.Genders.male)
    yield person('Karl',  'Kaivers', gender=mixins.Genders.male)
    yield person('Guido', 'Lambertz', gender=mixins.Genders.male)
    yield person('Laura', 'Laschet', gender=mixins.Genders.female)
    yield person('Line', 'Lazarus', gender=mixins.Genders.female)
    yield person('Josefine', 'Leffin', gender=mixins.Genders.female)
    yield person('Marc', 'Malmendier', gender=mixins.Genders.male)
    yield person('Melissa', 'Meessen', gender=mixins.Genders.female)
    yield person('Michael', 'Mießen', gender=mixins.Genders.male)
    yield person('Marie-Louise', 'Meier', gender=mixins.Genders.female)

    raeren = City.objects.get(name__exact='Raeren')
    person = Instantiator("partners.Person", "first_name last_name",
                          country='BE', language=settings.SITE.DEFAULT_LANGUAGE.django_code,
                          city=raeren, zip_code='4730').build
    yield person('Erich',    'Emonts', gender=mixins.Genders.male)
    yield person('Erwin',    'Emontspool', gender=mixins.Genders.male)
    yield person('Erna',     'Emonts-Gast', gender=mixins.Genders.female)
    yield person('Alfons',     'Radermacher', gender=mixins.Genders.male)
    yield person('Berta',     'Radermacher', gender=mixins.Genders.female)
    yield person('Christian',     'Radermacher', gender=mixins.Genders.male)
    yield person('Daniela',     'Radermacher', gender=mixins.Genders.female)
    yield person('Edgard',     'Radermacher', gender=mixins.Genders.male)
    yield person('Fritz',     'Radermacher', gender=mixins.Genders.male)
    yield person('Guido',     'Radermacher', gender=mixins.Genders.male)
    yield person('Hans',     'Radermacher', gender=mixins.Genders.male)
    yield person('Hedi',     'Radermacher', gender=mixins.Genders.female)
    yield person('Inge',     'Radermacher', gender=mixins.Genders.female)
    yield person('Jean',     'Radermacher', gender=mixins.Genders.male)

    # special challenges for alphabetic ordering
    yield person('Didier',     'di Rupo', gender=mixins.Genders.male)
    yield person('David', 'da Vinci', gender=mixins.Genders.male)
    yield person('Vincent',   'van Veen', gender=mixins.Genders.male)
    yield person('Rein',   'Õunapuu', gender=mixins.Genders.male)

    yield person('Otto',   'Östges', gender=mixins.Genders.male)
    yield person('Erna',   'Ärgerlich', gender=mixins.Genders.female)

    person = Instantiator("partners.Person", country='BE',
                          city=City.objects.get(name__exact='Angleur')).build
    yield person(first_name='Bernard', last_name='Bodard', title='Dr.')
    yield person(first_name='Jean', last_name='Dupont')

    #~ person = Instantiator("partners.Person",country='BE',city=City.objects.get(name__exact='Oostende')).build
    person = Instantiator("partners.Person", country='NL',
                          city=City.objects.get(name__exact='Amsterdam')).build
    yield person(first_name='Mark', last_name='Martelaer', gender=mixins.Genders.male)
    yield person(first_name='Rik', last_name='Radermecker', gender=mixins.Genders.male)
    yield person(first_name='Marie-Louise', last_name='Vandenmeulenbos', gender=mixins.Genders.female)

    person = Instantiator("partners.Person", country='DE').build
    yield person(first_name='Emil', last_name='Eierschal', gender=mixins.Genders.male)
    yield person(first_name='Lisa', last_name='Lahm', gender=mixins.Genders.female)
    yield person(first_name='Bernd', last_name='Brecht', gender=mixins.Genders.male)
    yield person(first_name='Karl', last_name='Keller', gender=mixins.Genders.male)

    person = Instantiator("partners.Person", country='FR').build
    yield person(first_name='Robin', last_name='Dubois', gender=mixins.Genders.male)
    yield person(first_name='Denis', last_name='Denon', gender=mixins.Genders.male)
    yield person(first_name='Jérôme', last_name='Jeanémart', gender=mixins.Genders.male)

    s = u"""\
Aachener Straße
Akazienweg
Alter Malmedyer Weg
Am Bahndamm
Am Berg
Am Waisenbüschchen
Auenweg
Auf dem Spitzberg
Auf'm Rain
August-Thonnar-Str.
Bahnhofsgasse
Bahnhofstraße
Bellmerin
Bennetsborn
Bergkapellstraße
Bergstraße
Binsterweg
Brabantstraße
Buchenweg
Edelstraße
Euregiostraße
Favrunpark
Feldstraße
Fränzel
Gewerbestraße
Gospert
Gülcherstraße
Haagenstraße
Haasberg
Haasstraße
Habsburgerweg
Heidberg
Heidgasse
Heidhöhe
Herbesthaler Straße
Hisselsgasse
Hochstraße
Hook
Hostert
Hufengasse
Hugo-Zimmermann-Str.
Hütte
Hütterprivatweg
Im Peschgen
In den Siepen
Industriestraße
Johannesstraße
Judenstraße
Kaperberg
Kaplan-Arnolds-Str.
Karl-Weiß-Str.
Kehrweg
Kirchgasse
Kirchstraße
Klinkeshöfchen
Kügelgasse
Langesthal
Lascheterweg
Limburgerweg
Lindenweg
Lothringerweg
Malmedyer Straße
Maria-Theresia-Straße
Marktplatz
Monschauer Straße
Mühlenweg
Neustraße
Nikolausfeld
Nispert
Noereth
Obere Ibern
Obere Rottergasse
Oestraße
Olengraben
Panorama
Paveestraße
Peter-Becker-Str.
Rosenweg
Rot-Kreuz-Str.
Rotenberg
Rotenbergplatz
Schilsweg
Schlüsselhof
Schnellewindgasse
Schönefeld
Schorberg
Schulstraße
Selterschlag
Simarstraße
Steinroth
Stendrich
Stockbergerweg
Stockem
Theodor-Mooren-Str.
Untere Ibern
Vervierser Straße
Vossengasse
Voulfeld
Werthplatz
Weserstraße
"""

    streets_of_eupen = [line.strip()
                        for line in s.splitlines() if len(line.strip()) > 0]

    i = 0
    nr = 1
    for p in resolve_model("partners.Person").objects.filter(city=eupen):
        p.street = streets_of_eupen[i]
        p.stret_no = str(nr)
        p.save()
        nr += 1
        if i < len(streets_of_eupen):
            i += 1
        else:
            i = 0
Esempio n. 27
0
#~ print 20120225, 'settings.FIXTURE_DIRS is', settings.FIXTURE_DIRS

dblogger.info("Imported contacts demo fixture")

COUNT = 0

#~ addresstype= Instantiator('contacts.AddressType',"name").build
role = Instantiator('contacts.Role',"name").build
#~ person = Instantiator('contacts.Person',"first_name last_name").build
#~ company = Instantiator('contacts.Company',"name").build
#~ contact = Instantiator('contacts.Contact').build

Company = contacts.Company
Person = contacts.Person
User = contacts.User
City = resolve_model('countries.City')

if not settings.SITE.abstract_address:
    Address = contacts.Address
    address = Instantiator(Address,"country zip_code city:name street street_no").build


def company(name,country_id,zip_code,city,street,street_no):
    if settings.SITE.abstract_address:
        city = City.objects.get(name=city)
        yield Company(name=name,country_id=country_id,zip_code=zip_code,
          city=city,street=street,street_no=street_no)
    else:
        addr = address(country_id,zip_code,city,street,street_no)
        yield addr
        com = Company(name=name,address=addr)
Esempio n. 28
0
import logging
logger = logging.getLogger(__name__)

#~ from django.utils import unittest
#~ from django.test.client import Client
#from lino.igen import models
#from lino.modlib.contacts.models import Contact, Companies
#from lino.modlib.countries.models import Country
#~ from lino.modlib.contacts.models import Companies

from lino.core.dbutils import resolve_model
#Companies = resolve_model('contacts.Companies')
from djangosite.utils.djangotest import TestCase

#~ Person = resolve_model('contacts.Person')
Invoice = resolve_model('sales.Invoice')
#~ Property = resolve_model('properties.Property')
#~ PersonProperty = resolve_model('properties.PersonProperty')

class DemoTest(TestCase):
    #~ fixtures = [ 'std','demo' ]
    fixtures = 'std few_countries few_languages few_cities demo'.split()
            
def test01(self):
    """
    """
    self.assertEqual(Invoice.objects.all().count(),28)
    i = Invoice.objects.all()[0]
    self.assertEqual(unicode(i),u"Invoice # 1")
    s = i.customer.address()
    self.assertEquals(s,u"""\
Esempio n. 29
0

from lino.utils import join_words
from lino.modlib.contacts.utils import name2kw, street2kw
#~ from lino.modlib.contacts.models import GENDER_MALE, GENDER_FEMALE
from lino import dd, rt
from lino.utils.instantiator import Instantiator

from lino.core.dbutils import resolve_model, obj2str
import lino

from lino.utils import confirm, iif
from lino.core.dbutils import app_labels
from lino.projects.crl.models import CRL

Country = resolve_model('countries.Country')
Place = resolve_model('countries.Place')
Person = resolve_model("contacts.Person")
Company = resolve_model("contacts.Company")


def parsedate(T):
    if not T:
        return
    T = T.replace('.', '')
    try:
        if len(T) == 4:
            return (datetime.date(int(T), 6, 30), True)
        elif len(T) == 6:
            return (datetime.date(int(T[:4]), int(T[4:6]), 15), True)
        elif len(T) == 8:
Esempio n. 30
0
File: std.py Progetto: raffas/lino
def objects():
    if False:
        Role = resolve_model('households.Role')

        kw = babel_values('name',
                          de=u"Familienoberhaupt",
                          fr=u"Chef de ménage",
                          en=u"Head of household"
        )
        yield Role(name_giving=True, **kw)
        kw = babel_values('name',
                          de=u"Ehepartner",
                          fr=u"Conjoint",
                          en=u"Spouse",
        )
        yield Role(name_giving=True, **kw)
        kw = babel_values('name',
                          de=u"Partner",
                          fr=u"Partenaire",
                          en=u"Partner",
        )
        yield Role(name_giving=True, **kw)
        kw = babel_values('name',
                          de=u"Mitbewohner",
                          fr=u"Cohabitant",
                          en=u"Cohabitant",
        )
        yield Role(**kw)
        kw = babel_values('name',
                          de=u"Kind",
                          fr=u"Enfant",
                          en=u"Child",
        )
        yield Role(**kw)

        kw = babel_values('name',
                          de=u"Verwandter",
                          fr=u"Membre de famille",
                          en=u"Relative",
        )
        yield Role(**kw)

        kw = babel_values('name',
                          de=u"Adoptivkind",
                          fr=u"Enfant adopté",
                          en=u"Adopted child",
        )
        yield Role(**kw)

    Type = resolve_model('households.Type')
    yield Type(**babel_values('name',
                              de=u"Ehepaar",
                              fr=u"Couple marié",
                              en=u"Married couple",
                              ))
    yield Type(**babel_values('name',
                              de=u"Familie",
                              fr=u"Famille",
                              en=u"Family",
                              ))
    yield Type(**babel_values('name',
                              de=u"Faktischer Haushalt",
                              fr=u"Ménage de fait",
                              en=u"Factual household",
                              ))
    yield Type(**babel_values('name',
                              de=u"Legale Wohngemeinschaft",
                              fr=u"Cohabitation légale",
                              en=u"Legal cohabitation",
                              ))
Esempio n. 31
0
    def class_init(self):
      
        if self.model is not None:
            self.model = resolve_model(self.model,self.app_label)
            
        if isinstance(self.model,UnresolvedModel):
            self.model = None
            
        if self.model is not None:
            if isinstance(self.hidden_columns,basestring):
                self.hidden_columns = frozenset(fields.fields_list(self.model,self.hidden_columns))
            self.hidden_columns = self.hidden_columns | self.model.hidden_columns
            self.hidden_elements = self.hidden_elements | self.model.hidden_elements
            
            #~ if self.model is not None:
              
            #~ for b in self.model.mro():
                #~ for k,v in b.__dict__.items():
                    #~ if isinstance(v,actions.Action):
                        #~ raise Exception("20130121 Must convert %s.%s to get_model_actions()" % (self.model,k))
            for b in self.model.mro():
                for k,v in b.__dict__.items():
                    #~ v = self.model.__dict__.get(k,v) # 20131025 allow disabling inherited actions
                    if isinstance(v,actions.Action):
                        #~ print "20130326 %s.%s = action %s from %s" % (self,k,v,b)
                        existing_value = self.__dict__.get(k,NOT_PROVIDED) 
                        if existing_value is NOT_PROVIDED:
                            setattr(self,k,v)
                        else:
                            if existing_value is None: # 20130820
                                pass
                                #~ logger.info("%s disables model action '%s'",self,k)
                                #~ self.unbind_action(k)
                            else:
                                if not isinstance(existing_value,actions.Action):
                                    raise Exception(
                                        "%s cannot install model action %s because name is already used for %r" %
                                        self,k,existing_value)

            for name in ('workflow_state_field','workflow_owner_field'):
                if getattr(self,name) is None:
                    setattr(self,name,getattr(self.model,name))
                    #~ v = getattr(self.model,name,None)
                    #~ if v is not None:
                        #~ setattr(self,name,v)
                        
            for name in ( #'disabled_fields',
                         'handle_uploaded_files', 
                         #~ 'get_row_permission', 
                         #~ 'disable_editing',
                         ):
                if getattr(self,name) is None:
                    m = getattr(self.model,name,None)
                    if m is not None:
                        #~ logger.debug('20120731 Install model method %s from %r to %r',name,self.model,self)
                        setattr(self,name,model2actor(m))
                        #~ 'dictproxy' object does not support item assignment:
                        #~ self.__dict__[name] = model2actor(m) 
                        
            if self.master_key:
                #~ assert self.model is not None, "%s has .master_key but .model is None" % self
                #~ self.master = resolve_model(self.master,self.app_label)
                master_model = None
                try:
                    fk, remote, direct, m2m = self.model._meta.get_field_by_name(self.master_key)
                    assert direct
                    assert not m2m
                    #~ if fk.rel is None:
                        #~ raise Exception("%s.master_key %r is not a RelatedField" % (self,self.master_key))
                    if fk.rel is not None:
                        master_model = fk.rel.to
                except models.FieldDoesNotExist,e:
                    #~ logger.debug("FieldDoesNotExist in %r._meta.get_field_by_name(%r)",self.model,self.master_key)
                    for vf in self.model._meta.virtual_fields:
                        if vf.name == self.master_key:
                            fk = vf
                            master_model = ContentType
                            break
                if master_model is None:
                    raise Exception("%s : no master for master_key %r in %s" % (
                        self,self.master_key,self.model))
                self.master = master_model
                #~ self.fk = fk
                self.master_field = fk