Ejemplo n.º 1
0
 def _add_season_comp(self, xfer, row):
     season = self.item.season
     if self.item.subscriptiontype.duration == 0:  # annually
         lbl = XferCompLabelForm("seasondates")
         lbl.set_location(1, row)
         lbl.set_value(
             "%s => %s" %
             (formats.date_format(season.begin_date, "SHORT_DATE_FORMAT"),
              formats.date_format(season.end_date, "SHORT_DATE_FORMAT")))
         lbl.description = _('annually')
         xfer.add_component(lbl)
     elif self.item.subscriptiontype.duration == 1:  # periodic
         sel = XferCompSelect('period')
         sel.set_needed(True)
         sel.set_select_query(season.period_set.all())
         sel.set_location(1, row)
         sel.description = _('period')
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 2:  # monthly
         sel = XferCompSelect('month')
         sel.set_needed(True)
         sel.set_select(season.get_months())
         sel.set_location(1, row)
         sel.description = _('month')
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         begindate = XferCompDate('begin_date')
         begindate.set_needed(True)
         begindate.set_value(season.date_ref)
         begindate.set_location(1, row)
         begindate.description = _('begin date')
         xfer.add_component(begindate)
Ejemplo n.º 2
0
 def edit(self, xfer):
     date = XferCompDate('begin_date')
     date.set_location(1, 0)
     date.set_needed(True)
     date.description = _('begin date')
     val = Period.objects.all().aggregate(Max('end_date'))
     if ('end_date__max' in val.keys()) and (val['end_date__max']
                                             is not None):
         date.set_value(val['end_date__max'] + timedelta(days=1))
     xfer.add_component(date)
Ejemplo n.º 3
0
 def fillresponse(self, limit_date=''):
     if limit_date == '':
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 6)
         dlg.add_component(img)
         lbl = XferCompLabelForm('lb_limit_date')
         lbl.set_value_as_name(_('limit date'))
         lbl.set_location(1, 1, 1)
         dlg.add_component(lbl)
         limite_date = XferCompDate('limit_date')
         limite_date.set_needed(True)
         limite_date.set_value((date.today() - timedelta(weeks=25)))
         limite_date.set_location(1, 2, 1)
         dlg.add_component(limite_date)
         dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         third_ids = [val_third['third'] for val_third in EntryLineAccount.objects.filter(
             entry__date_value__gt=limit_date, third__gt=0).values('third')]
         for third in Third.objects.filter(status=0):
             if third.id not in third_ids:
                 third.status = 1
                 third.save()
Ejemplo n.º 4
0
    def fillresponse(self, flt1=0.0, flt2=0, dt1='01-01-2010', tm1='12:00', stm1='01-01-2010 12:00'):
        act_modif = self.get_action('Modify', '')

        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(0, 1)
        flt.needed = False
        flt.description = 'Real=' + six.text_type(flt1)
        self.add_component(flt)

        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(0, 2)
        flt.needed = False
        flt.description = 'Integer=' + six.text_type(flt2)
        self.add_component(flt)

        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        date.set_location(0, 3)
        date.needed = False
        date.description = 'Date=' + six.text_type(dt1)
        self.add_component(date)

        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        time.set_location(0, 4)
        time.needed = False
        time.description = 'Hour=' + six.text_type(tm1)
        self.add_component(time)

        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        datetime.set_location(0, 5)
        datetime.needed = False
        datetime.description = 'Date Hour=' + six.text_type(stm1)
        self.add_component(datetime)
Ejemplo n.º 5
0
 def edit(self, xfer):
     lbl = XferCompLabelForm('lbl_begin_date')
     lbl.set_value_as_name(_('begin date'))
     lbl.set_location(1, 0)
     xfer.add_component(lbl)
     date = XferCompDate('begin_date')
     date.set_location(2, 0)
     date.set_needed(True)
     val = Period.objects.all().aggregate(Max('end_date'))
     if ('end_date__max' in val.keys()) and (val['end_date__max'] is not None):
         date.set_value(val['end_date__max'] + timedelta(days=1))
     xfer.add_component(date)
Ejemplo n.º 6
0
    def fillresponse(self, flt1=0.0, flt2=0, dt1='01-01-2010', tm1='12:00', stm1='01-01-2010 12:00'):
        act_modif = self.get_action('Modify', '')

        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(0, 1)
        flt.needed = False
        flt.description = 'Real=' + six.text_type(flt1)
        self.add_component(flt)

        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(0, 2)
        flt.needed = False
        flt.description = 'Integer=' + six.text_type(flt2)
        self.add_component(flt)

        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        date.set_location(0, 3)
        date.needed = False
        date.description = 'Date=' + six.text_type(dt1)
        self.add_component(date)

        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        time.set_location(0, 4)
        time.needed = False
        time.description = 'Hour=' + six.text_type(tm1)
        self.add_component(time)

        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        datetime.set_location(0, 5)
        datetime.needed = False
        datetime.description = 'Date Hour=' + six.text_type(stm1)
        self.add_component(datetime)
Ejemplo n.º 7
0
    def fillresponse_search_values(self):
        comp = XferCompButton("searchButtonAdd")
        comp.is_default = True
        comp.set_is_mini(True)
        comp.set_location(4, 10, 1, 7)
        comp.set_action(self.request,
                        self.get_action("", "images/add.png"),
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO,
                        params={'ACT': 'ADD'})
        self.add_component(comp)

        comp = XferCompDate("searchValueDate")
        comp.set_needed(True)
        comp.set_location(3, 11)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompFloat("searchValueFloat")
        comp.set_needed(True)
        comp.set_location(3, 12)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompEdit("searchValueStr")
        comp.set_location(3, 13)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompCheckList("searchValueList")
        comp.set_location(3, 14)
        comp.set_size(80, 200)
        self.add_component(comp)
        comp = XferCompCheck("searchValueBool")
        comp.set_location(3, 15)
        comp.set_size(20, 200)
        self.add_component(comp)
        comp = XferCompTime("searchValueTime")
        comp.set_needed(True)
        comp.set_location(3, 16)
        comp.set_size(20, 200)
        self.add_component(comp)

        label = XferCompLabelForm('labelsearchSep')
        label.set_value("")
        label.set_size(1, 200)
        label.set_location(3, 17)
        self.add_component(label)
Ejemplo n.º 8
0
    def fillresponse(self, begin_date, end_date):
        self.item.set_dates(begin_date, end_date)
        lbl = XferCompLabelForm('lbl_begin_date')
        lbl.set_value_as_name(_('initial date'))
        lbl.set_location(1, 0)
        self.add_component(lbl)
        date_init = XferCompDate("begin_date")
        date_init.set_needed(True)
        date_init.set_value(self.item.date_begin)
        date_init.set_location(2, 0)
        date_init.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(date_init)
        lbl = XferCompLabelForm('lbl_end_date')
        lbl.set_value_as_name(_('current date'))
        lbl.set_location(3, 0)
        self.add_component(lbl)
        date_end = XferCompDate("end_date")
        date_end.set_needed(True)
        date_end.set_value(self.item.date_end)
        date_end.set_location(4, 0)
        date_end.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(date_end)

        XferShowEditor.fillresponse(self)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Show', self),
                        close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Email', self),
                        close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0)
Ejemplo n.º 9
0
    def fillresponse(self, edt1='aaa', flt1=3.1399999, mm1='xyz', dt1='2007-04-23', tm1='12:34:00',
                     ck1=False, slct1='1', flt2=5, cl1=['1', '2'], cl2=['b', 'd', 'f'], stm1='2008-07-12 23:47:31'):
        act_modif = self.get_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select(
            {'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        checklist.set_value(cl1)
        checklist.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select(
            {'a': '123', 'b': '456', 'c': '789', 'd': '147', 'e': '258', 'f': '369'})
        checklist.set_value(cl2)
        checklist.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request, act_modif, modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES)
Ejemplo n.º 10
0
    def get_writing_comp(self, field_name):
        def get_value_from_field(default):
            try:
                val = getattr(self.item, field_name)
            except ObjectDoesNotExist:
                getLogger("lucterios.core").exception(
                    "fieldname '%s' not found", field_name)
                val = None
            if val is None:
                if is_needed:
                    if dep_field.default != NOT_PROVIDED:
                        val = dep_field.default
                    else:
                        val = default
            return val

        from django.db.models.fields import IntegerField, DecimalField, BooleanField, TextField, DateField, TimeField, DateTimeField, CharField
        from django.db.models.fields.related import ForeignKey
        dep_field = self.item.get_field_by_name(field_name)
        is_needed = dep_field.unique or not (dep_field.blank or dep_field.null)
        if isinstance(dep_field, IntegerField):
            if (dep_field.choices
                    is not None) and (len(dep_field.choices) > 0):
                comp = XferCompSelect(field_name)
                comp.set_select(list(dep_field.choices))
                min_value = 0
            else:
                min_value, max_value = get_range_value(dep_field)
                comp = XferCompFloat(field_name, min_value, max_value, 0)
            comp.set_value(get_value_from_field(min_value))
        elif isinstance(dep_field, DecimalField):
            min_value, max_value = get_range_value(dep_field)
            comp = XferCompFloat(field_name, min_value, max_value,
                                 dep_field.decimal_places)
            comp.set_value(get_value_from_field(min_value))
        elif isinstance(dep_field, BooleanField):
            comp = XferCompCheck(field_name)
            comp.set_value(get_value_from_field(False))
        elif isinstance(dep_field, TextField):
            comp = XferCompMemo(field_name)
            comp.set_value(get_value_from_field(""))
        elif isinstance(dep_field, DateField):
            comp = XferCompDate(field_name)
            comp.set_value(get_value_from_field(datetime.date.today()))
        elif isinstance(dep_field, TimeField):
            comp = XferCompTime(field_name)
            comp.set_value(get_value_from_field(datetime.time()))
        elif isinstance(dep_field, DateTimeField):
            comp = XferCompDateTime(field_name)
            comp.set_value(get_value_from_field(datetime.datetime.now()))
        elif isinstance(dep_field, ForeignKey):
            comp = XferCompSelect(field_name)
            try:
                value = self.item
                for fieldname in field_name.split('.'):
                    value = getattr(value, fieldname)
            except ObjectDoesNotExist:
                value = None
            if value is None:
                comp.set_value(0)
            else:
                comp.set_value(value.id)
            if hasattr(self.item, fieldname + '_query'):
                sub_select = getattr(self.item, fieldname + '_query')
            else:
                sub_select = dep_field.remote_field.model.objects.all()
            comp.set_needed(not dep_field.null)
            comp.set_select_query(sub_select)
        elif (dep_field is not None
              ) and dep_field.is_relation and dep_field.many_to_many:
            comp = XferCompCheckList(field_name)
            comp.simple = 2
            if self.item.id is not None:
                values = []
                for item in getattr(self.item, field_name).all():
                    values.append(item.id)
                comp.set_value(values)
            if hasattr(self.item, field_name + '_query'):
                sub_select = getattr(self.item, field_name + '_query')
            else:
                sub_select = get_dico_from_setquery(
                    get_corrected_setquery(
                        dep_field.remote_field.model.objects.all()))
            comp.set_select(sub_select)
        else:
            comp = XferCompEdit(field_name)
            comp.set_value(get_value_from_field(""))
            if isinstance(dep_field, CharField):
                comp.size = dep_field.max_length
        comp.set_needed(is_needed)
        return comp
Ejemplo n.º 11
0
    def fillresponse(self,
                     edt1='aaa',
                     flt1=3.1399999,
                     mm1='xyz',
                     dt1='2007-04-23',
                     tm1='12:34:00',
                     ck1=False,
                     slct1='1',
                     flt2=5,
                     cl1=['1', '2'],
                     cl2=['b', 'd', 'f'],
                     stm1='2008-07-12 23:47:31'):
        act_modif = self.return_action('Modify', '')

        lbl = XferCompLabelForm('Lbl2')
        lbl.set_value('editor=' + six.text_type(edt1))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        edt = XferCompEdit('edt1')
        edt.set_value(edt1)

        edt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        edt.set_location(1, 1)

        self.add_component(edt)

        lbl = XferCompLabelForm('Lbl3')
        lbl.set_value('Real=' + six.text_type(flt1))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        flt = XferCompFloat('flt1')
        flt.set_value(flt1)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 2)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl4')
        lbl.set_value('Memo=' + six.text_type(mm1))
        lbl.set_location(0, 3)
        self.add_component(lbl)
        cmm = XferCompMemo('mm1')
        cmm.set_value(mm1)
        cmm.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        cmm.add_sub_menu('Première valeur', 'VALUE_1')
        cmm.add_sub_menu('Deuxième valeur', 'VALUE_2')
        cmm.add_sub_menu('Troisième valeur', 'VALUE_3')
        cmm.set_location(1, 3)
        self.add_component(cmm)

        lbl = XferCompLabelForm('Lbl5')
        lbl.set_value('Date=' + six.text_type(dt1))
        lbl.set_location(0, 4)
        self.add_component(lbl)
        date = XferCompDate('dt1')
        date.set_value(dt1)
        date.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        date.set_location(1, 4)
        self.add_component(date)

        lbl = XferCompLabelForm('Lbl6')
        lbl.set_value('Hour=' + six.text_type(tm1))
        lbl.set_location(0, 5)
        self.add_component(lbl)
        time = XferCompTime('tm1')
        time.set_value(tm1)
        time.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        time.set_location(1, 5)
        self.add_component(time)

        lbl = XferCompLabelForm('Lbl7')
        lbl.set_value('Date Hour=' + six.text_type(stm1))
        lbl.set_location(0, 6)
        self.add_component(lbl)
        datetime = XferCompDateTime('stm1')
        datetime.set_value(stm1)
        datetime.set_action(self.request,
                            act_modif,
                            modal=FORMTYPE_REFRESH,
                            close=CLOSE_NO)
        datetime.set_location(1, 6)
        self.add_component(datetime)

        lbl = XferCompLabelForm('Lbl8')
        lbl.set_value('Coche=' + six.text_type(ck1))
        lbl.set_location(0, 7)
        self.add_component(lbl)
        check = XferCompCheck('ck1')
        check.set_value(ck1)
        check.set_action(self.request,
                         act_modif,
                         modal=FORMTYPE_REFRESH,
                         close=CLOSE_NO)
        check.set_location(1, 7)
        self.add_component(check)

        lbl = XferCompLabelForm('Lbl9')
        lbl.set_value('Select=' + six.text_type(slct1))
        lbl.set_location(0, 8)
        self.add_component(lbl)
        slct = XferCompSelect('slct1')
        if (flt2 is not None) and (flt2 < 2):
            slct.set_select({'1': 'abc', '2': 'def'})
        elif (flt2 is not None) and (flt2 < 10):
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij'})
        else:
            slct.set_select({'1': 'abc', '2': 'def', '3': 'ghij', '4': 'klmn'})
        slct.set_value(slct1)
        slct.set_action(self.request,
                        act_modif,
                        modal=FORMTYPE_REFRESH,
                        close=CLOSE_NO)
        slct.set_location(1, 8)
        self.add_component(slct)

        lbl = XferCompLabelForm('Lbl10')
        lbl.set_value('Integer=' + six.text_type(flt2))
        lbl.set_location(0, 9)
        self.add_component(lbl)
        flt = XferCompFloat('flt2', 0, 100, 0)
        flt.set_value(flt2)
        flt.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        flt.set_location(1, 9)
        self.add_component(flt)

        lbl = XferCompLabelForm('Lbl11')
        lbl.set_value('CheckList=' + six.text_type(cl1))
        lbl.set_location(0, 10)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl1')
        checklist.set_select({
            '1': 'abc',
            '2': 'def',
            '3': 'ghij',
            '4': 'klmn'
        })
        checklist.set_value(cl1)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 10)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl12')
        lbl.set_value('CheckList 2=' + six.text_type(cl2))
        lbl.set_location(0, 11)
        self.add_component(lbl)
        checklist = XferCompCheckList('cl2')
        checklist.simple = 2
        checklist.set_select({
            'a': '123',
            'b': '456',
            'c': '789',
            'd': '147',
            'e': '258',
            'f': '369'
        })
        checklist.set_value(cl2)
        checklist.set_action(self.request,
                             act_modif,
                             modal=FORMTYPE_REFRESH,
                             close=CLOSE_NO)
        checklist.set_location(1, 11)
        self.add_component(checklist)

        lbl = XferCompLabelForm('Lbl13')
        lbl.set_value('Bouton')
        lbl.set_location(0, 20)
        self.add_component(lbl)
        btn = XferCompButton('btn1')
        btn.set_action(self.request,
                       act_modif,
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        btn.set_location(1, 20)
        self.add_component(btn)

        self.add_action(WrapAction('Fin', 'images/close.png'),
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_YES)
Ejemplo n.º 12
0
    def fillresponse(self, begin_date, end_date):
        self.item.set_dates(begin_date, end_date)
        date_init = XferCompDate("begin_date")
        date_init.set_needed(True)
        date_init.set_value(self.item.date_begin)
        date_init.set_location(1, 0)
        date_init.description = _('initial date')
        date_init.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(date_init)
        date_end = XferCompDate("end_date")
        date_end.set_needed(True)
        date_end.set_value(self.item.date_end)
        date_end.set_location(2, 0)
        date_end.description = _('current date')
        date_end.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(date_end)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        self.add_component(img)
        self.fill_from_model(1, 1, True, [((_('name'), 'third'),)])
        grid = XferCompGrid('loadcount')
        grid.set_model(self.item.loadcount_set.all(), None)
        grid.set_location(1, 2, 2)
        self.add_component(grid)

        self.add_action(WrapAction(_('Close'), 'images/close.png'))
Ejemplo n.º 13
0
 def edit(self, xfer):
     autocreate = xfer.getparam('autocreate', 0) == 1
     xfer.change_to_readonly("adherent")
     cmp_status = xfer.get_components('status')
     if autocreate:
         if Params.getvalue("member-subscription-mode") == 2:
             status = 1
         else:
             status = 0
         cmp_status.set_value(status)
         xfer.change_to_readonly("status")
         xfer.params['status'] = status
     elif self.item.id is None:
         del cmp_status.select_list[0]
         del cmp_status.select_list[-2]
         del cmp_status.select_list[-1]
     else:
         xfer.change_to_readonly("status")
     last_subscription = self.item.adherent.last_subscription
     cmp_subscriptiontype = xfer.get_components('subscriptiontype')
     if (self.item.id is not None) or autocreate:
         xfer.change_to_readonly('season')
     else:
         cmp_season = xfer.get_components('season')
         if self.item.season_id is None:
             self.item.season = Season.current_season()
             cmp_season.set_value(self.item.season.id)
         cmp_season.set_action(xfer.request, xfer.get_action(),
                               close=CLOSE_NO, modal=FORMTYPE_REFRESH)
         if (last_subscription is not None) and (xfer.getparam('subscriptiontype') is None):
             cmp_subscriptiontype.set_value(
                 last_subscription.subscriptiontype.id)
     if self.item.subscriptiontype_id is None:
         if len(cmp_subscriptiontype.select_list) == 0:
             raise LucteriosException(IMPORTANT, _("No subscription type defined!"))
         cmp_subscriptiontype.get_reponse_xml()
         self.item.subscriptiontype = SubscriptionType.objects.get(
             id=cmp_subscriptiontype.value)
     cmp_subscriptiontype.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     row = xfer.get_max_row() + 1
     season = self.item.season
     if self.item.subscriptiontype.duration == 0:  # annually
         lbl = XferCompLabelForm("lbl_seasondates")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('annually'))
         xfer.add_component(lbl)
         lbl = XferCompLabelForm("seasondates")
         lbl.set_location(2, row)
         lbl.set_value("%s => %s" % (formats.date_format(
             season.begin_date, "SHORT_DATE_FORMAT"), formats.date_format(season.end_date, "SHORT_DATE_FORMAT")))
         xfer.add_component(lbl)
     elif self.item.subscriptiontype.duration == 1:  # periodic
         lbl = XferCompLabelForm("lbl_period")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('period'))
         xfer.add_component(lbl)
         sel = XferCompSelect('period')
         sel.set_needed(True)
         sel.set_select_query(season.period_set.all())
         sel.set_location(2, row)
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 2:  # monthly
         lbl = XferCompLabelForm("lbl_month")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('month'))
         xfer.add_component(lbl)
         sel = XferCompSelect('month')
         sel.set_needed(True)
         sel.set_select(season.get_months())
         sel.set_location(2, row)
         xfer.add_component(sel)
     elif self.item.subscriptiontype.duration == 3:  # calendar
         lbl = XferCompLabelForm("lbl_begin_date")
         lbl.set_location(1, row)
         lbl.set_value_as_name(_('begin date'))
         xfer.add_component(lbl)
         begindate = XferCompDate('begin_date')
         begindate.set_needed(True)
         begindate.set_value(season.date_ref)
         begindate.set_location(2, row)
         xfer.add_component(begindate)
     if self.item.id is None:
         xfer.item = License()
         if last_subscription is not None:
             licenses = last_subscription.license_set.all()
             if len(licenses) > 0:
                 xfer.item = licenses[0]
         xfer.fill_from_model(1, row + 1, False)
         xfer.item = self.item
         team = xfer.get_components('team')
         if team is not None:
             team.set_needed(True)
         activity = xfer.get_components('activity')
         if activity is not None:
             activity.set_needed(True)
Ejemplo n.º 14
0
    def fillresponse(self, begin_date, end_date):
        self.item.set_dates(begin_date, end_date)
        date_init = XferCompDate("begin_date")
        date_init.set_needed(True)
        date_init.set_value(self.item.date_begin)
        date_init.set_location(1, 0)
        date_init.description = _('initial date')
        date_init.set_action(self.request,
                             self.get_action(),
                             close=CLOSE_NO,
                             modal=FORMTYPE_REFRESH)
        self.add_component(date_init)
        date_end = XferCompDate("end_date")
        date_end.set_needed(True)
        date_end.set_value(self.item.date_end)
        date_end.set_location(3, 0)
        date_end.description = _('current date')
        date_end.set_action(self.request,
                            self.get_action(),
                            close=CLOSE_NO,
                            modal=FORMTYPE_REFRESH)
        self.add_component(date_end)

        XferShowEditor.fillresponse(self)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting',
                                                     'Show', self),
                        close=CLOSE_NO,
                        params={'item_name': self.field_id},
                        pos_act=0)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting',
                                                     'Email', self),
                        close=CLOSE_NO,
                        params={'item_name': self.field_id},
                        pos_act=0)
Ejemplo n.º 15
0
 def _create_comp_datefield(self, field_name, dep_field):
     comp = XferCompDate(field_name)
     comp.set_value(
         self._get_value_from_field(field_name, dep_field,
                                    datetime.date.today()))
     return comp
Ejemplo n.º 16
0
    def fillresponse_header(self):
        row = self.get_max_row() + 1
        team = self.getparam("team", ())
        activity = self.getparam("activity", ())
        genre = self.getparam("genre", 0)
        age = self.getparam("age", ())
        status = self.getparam("status", -1)
        dateref = convert_date(
            self.getparam("dateref", ""), Season.current_season().date_ref)

        if Params.getvalue("member-age-enable"):
            lbl = XferCompLabelForm('lblage')
            lbl.set_value_as_name(_("Age"))
            lbl.set_location(0, row)
            self.add_component(lbl)
            sel = XferCompCheckList('age')
            sel.set_select_query(Age.objects.all())
            sel.set_value(age)
            sel.set_location(1, row, 1, 2)
            self.add_component(sel)

        if Params.getvalue("member-team-enable"):
            lbl = XferCompLabelForm('lblteam')
            lbl.set_value_as_name(Params.getvalue("member-team-text"))
            lbl.set_location(2, row)
            self.add_component(lbl)
            sel = XferCompCheckList('team')
            sel.set_select_query(Team.objects.all())
            sel.set_value(team)
            sel.set_location(3, row, 1, 2)
            self.add_component(sel)

        if Params.getvalue("member-activite-enable"):
            lbl = XferCompLabelForm('lblactivity')
            lbl.set_value_as_name(Params.getvalue("member-activite-text"))
            lbl.set_location(4, row)
            self.add_component(lbl)
            sel = XferCompCheckList('activity')
            sel.set_select_query(Activity.objects.all())
            sel.set_value(activity)
            sel.set_location(5, row, 1, 2)
            self.add_component(sel)

        lbl = XferCompLabelForm('lbldateref')
        lbl.set_value_as_name(_("reference date"))
        lbl.set_location(6, row)
        self.add_component(lbl)

        dtref = XferCompDate('dateref')
        dtref.set_value(dateref)
        dtref.set_needed(True)
        dtref.set_location(7, row, 2)
        self.add_component(dtref)

        if Params.getvalue("member-filter-genre"):
            lbl = XferCompLabelForm('lblgenre')
            lbl.set_value_as_name(_("genre"))
            lbl.set_location(6, row + 1)
            self.add_component(lbl)
            sel = XferCompSelect('genre')
            list_genre = list(self.item.get_field_by_name('genre').choices)
            list_genre.insert(0, (0, '---'))
            sel.set_select(list_genre)
            sel.set_location(7, row + 1)
            sel.set_value(genre)
            self.add_component(sel)

        lbl = XferCompLabelForm('lblstatus')
        lbl.set_value_as_name(_("status"))
        lbl.set_location(6, row + 2)
        self.add_component(lbl)
        sel = XferCompSelect('status')
        list_status = list(Subscription.get_field_by_name('status').choices)
        del list_status[0]
        del list_status[-2]
        del list_status[-1]
        list_status.insert(0, (-1, '%s & %s' % (_('building'), _('valid'))))
        sel.set_select(list_status)
        sel.set_location(7, row + 2)
        sel.set_value(status)
        self.add_component(sel)

        btn = XferCompButton('btndateref')
        btn.set_location(8, row + 1, 1, 2)
        btn.set_action(self.request, self.get_action(_('Refresh'), ''),
                       modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(btn)
Ejemplo n.º 17
0
 def fillresponse(self, begin_date, end_date):
     self.item.set_dates(begin_date, end_date)
     date_init = XferCompDate("begin_date")
     date_init.set_needed(True)
     date_init.set_value(self.item.date_begin)
     date_init.set_location(1, 0)
     date_init.description = _('initial date')
     date_init.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(date_init)
     date_end = XferCompDate("end_date")
     date_end.set_needed(True)
     date_end.set_value(self.item.date_end)
     date_end.set_location(3, 0)
     date_end.description = _('current date')
     date_end.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(date_end)
     XferShowEditor.fillresponse(self)