Exemplo 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)
Exemplo n.º 2
0
    def edit(self, xfer):
        if xfer.item.id is None:
            third = xfer.get_components('third')
            xfer.remove_component('third')
            xfer.remove_component('lbl_third')
            lbl = XferCompLabelForm('lbl_third')
            lbl.set_location(third.col - 1, third.row)
            lbl.set_value_as_name(_('third'))
            xfer.add_component(lbl)

            sel = XferCompSelect('third')
            sel.needed = True
            sel.set_location(third.col, third.row)
            owner_third_ids = []
            for owner in Owner.objects.all():
                owner_third_ids.append(owner.third_id)
            items = Third.objects.all().exclude(id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: six.text_type(t))
            sel.set_select_query(items)
            xfer.add_component(sel)
            btn = XferCompButton('add_third')
            btn.set_location(3, 0)
            btn.set_is_mini(True)
            btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.Third', 'Add', xfer), close=CLOSE_NO,
                           modal=FORMTYPE_MODAL, params={'new_account': Params.getvalue('condominium-default-owner-account')})
            xfer.add_component(btn)
        else:
            xfer.change_to_readonly('third')
Exemplo n.º 3
0
 def fillresponse_add_title(self):
     XferSearchEditor.fillresponse_add_title(self)
     modelname = self.model.get_long_name()
     saved_list = SavedCriteria.objects.filter(modelname=modelname)
     new_row = self.get_max_row()
     sel = XferCompSelect('saved_criteria')
     sel.description = _("saved criteria")
     sel.set_location(1, new_row + 1, 3)
     sel.set_needed(False)
     sel.set_select_query(saved_list)
     sel.set_action(self.request,
                    self.return_action(),
                    close=CLOSE_NO,
                    modal=FORMTYPE_REFRESH)
     self.add_component(sel)
     if len(self.criteria_list) > 0:
         from lucterios.CORE.views import SavedCriteriaAddModify
         btn = XferCompButton('btn_saved_criteria')
         btn.set_location(4, new_row + 1, 2)
         btn.set_is_mini(True)
         btn.set_action(self.request,
                        SavedCriteriaAddModify.get_action("+", ""),
                        close=CLOSE_NO,
                        params={
                            'modelname': modelname,
                            'criteria': self.getparam('CRITERIA', '')
                        })
         self.add_component(btn)
     if self.getparam('saved_criteria', 0) != 0:
         saved_item = SavedCriteria.objects.get(
             id=self.getparam('saved_criteria', 0))
         self.params['CRITERIA'] = saved_item.criteria
         self.read_criteria_from_params()
Exemplo n.º 4
0
 def fillresponse(self, costaccounting=0):
     if self.getparam("SAVE") is None:
         dlg = self.create_custom()
         icon = XferCompImage('img')
         icon.set_location(0, 0, 1, 6)
         icon.set_value(self.icon_path())
         dlg.add_component(icon)
         lbl = XferCompLabelForm('lb_costaccounting')
         lbl.set_value_as_name(CostAccounting._meta.verbose_name)
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         sel = XferCompSelect('costaccounting')
         sel.set_select_query(CostAccounting.objects.filter(status=0))
         if self.item is not None:
             sel.set_value(self.item.costaccounting_id)
         sel.set_location(1, 2)
         dlg.add_component(sel)
         dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"})
         dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
     else:
         if costaccounting == 0:
             new_cost = None
         else:
             new_cost = CostAccounting.objects.get(id=costaccounting)
         for item in self.items:
             if (item.costaccounting is None) or (item.costaccounting.status == 0):
                 item.costaccounting = new_cost
                 item.save()
Exemplo n.º 5
0
 def fillresponse_add_title(self):
     XferSearchEditor.fillresponse_add_title(self)
     modelname = self.model.get_long_name()
     saved_list = SavedCriteria.objects.filter(modelname=modelname)
     new_row = self.get_max_row()
     lbl = XferCompLabelForm('lbl_saved_criteria')
     lbl.set_location(1, new_row + 1)
     lbl.set_value_as_name(_("saved criteria"))
     self.add_component(lbl)
     sel = XferCompSelect('saved_criteria')
     sel.set_location(2, new_row + 1, 2)
     sel.set_needed(False)
     sel.set_select_query(saved_list)
     sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
     self.add_component(sel)
     if len(self.criteria_list) > 0:
         from lucterios.CORE.views import SavedCriteriaAddModify
         btn = XferCompButton('btn_saved_criteria')
         btn.set_location(4, new_row + 1, 2)
         btn.set_is_mini(True)
         btn.set_action(self.request, SavedCriteriaAddModify.get_action("+", ""), close=CLOSE_NO,
                        params={'modelname': modelname, 'criteria': self.getparam('CRITERIA', '')})
         self.add_component(btn)
     if self.getparam('saved_criteria', 0) != 0:
         saved_item = SavedCriteria.objects.get(
             id=self.getparam('saved_criteria', 0))
         self.params['CRITERIA'] = saved_item.criteria
         self.read_criteria_from_params()
Exemplo n.º 6
0
    def fill_header(self):
        self.item = FiscalYear.get_current(self.getparam("year"))
        new_begin = convert_date(self.getparam("begin"), self.item.begin)
        new_end = convert_date(self.getparam("end"), self.item.end)
        if (new_begin >= self.item.begin) and (new_end <= self.item.end):
            self.item.begin = new_begin
            self.item.end = new_end
        img = XferCompImage('img')
        img.set_value(self.current_image())
        if not img.value.startswith('/static/'):
            img.type = 'jpg'
        img.set_location(0, 0, 1, 5)
        self.add_component(img)

        if self.item.last_fiscalyear is not None:
            lbl = XferCompLabelForm('year_1')
            lbl.set_location(1, 0, 3)
            lbl.description = _('year N-1')
            lbl.set_value(six.text_type(self.item.last_fiscalyear))
            self.add_component(lbl)
        select_year = XferCompSelect(self.field_id)
        select_year.set_location(1, 1, 3)
        select_year.set_select_query(FiscalYear.objects.all())
        select_year.description = _('year N')
        select_year.set_value(self.item.id)
        select_year.set_needed(True)
        select_year.set_action(self.request,
                               self.__class__.get_action(),
                               close=CLOSE_NO,
                               modal=FORMTYPE_REFRESH)
        self.add_component(select_year)
        self.filter = Q(entry__year=self.item)
        self.lastfilter = Q(entry__year=self.item.last_fiscalyear)
Exemplo n.º 7
0
def editbudget_condo(xfer):
    if xfer.getparam('set') is not None:
        cost = xfer.getparam('cost_accounting')
        if cost is not None:
            set_item = Set.objects.get(id=xfer.getparam('set', 0))
            title_cost = xfer.get_components('title_cost')
            xfer.remove_component('title_year')
            year = xfer.getparam('year', 0)
            select_year = XferCompSelect('year')
            select_year.set_location(1, title_cost.row - 1)
            select_year.set_select_query(FiscalYear.objects.all())
            select_year.set_value(year)
            select_year.description = _('year')
            select_year.set_needed(set_item.type_load == Set.TYPELOAD_CURRENT)
            select_year.set_action(xfer.request,
                                   xfer.__class__.get_action(),
                                   close=CLOSE_NO,
                                   modal=FORMTYPE_REFRESH)
            xfer.add_component(select_year)
            btn = XferCompButton('confyear')
            btn.set_location(2, title_cost.row - 1)
            btn.set_action(xfer.request,
                           ActionsManage.get_action_url(
                               FiscalYear.get_long_name(), 'configuration',
                               xfer),
                           close=CLOSE_NO)
            btn.set_is_mini(True)
            xfer.add_component(btn)
            if year != 0:
                current_year = FiscalYear.get_current(year)
                xfer.params['readonly'] = str(
                    current_year.status == FiscalYear.STATUS_FINISHED)
                if set_item.type_load == 0:
                    if len(set_item.setcost_set.filter(
                            year=current_year)) == 0:
                        set_item.create_new_cost(year=current_year.id)
                    setcost_item = set_item.setcost_set.filter(
                        year=current_year)[0]
                else:
                    setcost_item = set_item.setcost_set.filter(year=None)[0]
                cost_item = setcost_item.cost_accounting
                xfer.params['cost_accounting'] = cost_item.id
                title_cost.set_value("{[b]}%s{[/b]} : %s" %
                                     (_('cost accounting'), cost_item))
            else:
                year = None
                xfer.params['readonly'] = 'True'
                cost_item = CostAccounting.objects.get(id=cost)
            if (cost_item.status
                    == CostAccounting.STATUS_OPENED) and not xfer.getparam(
                        'readonly', False):
                set_item.change_budget_product(cost_item, year)
    if xfer.getparam('type_of_account') is not None:
        xfer.params['readonly'] = 'True'
    return
Exemplo n.º 8
0
    def edit(self, xfer):
        if xfer.item.id is None:
            new_account = []
            if Params.getvalue("condominium-old-accounting"):
                new_account.append(
                    Params.getvalue("condominium-default-owner-account"))
            else:
                for num_account in LIST_DEFAULT_ACCOUNTS:
                    new_account.append(
                        Params.getvalue("condominium-default-owner-account%d" %
                                        num_account))
            sel = XferCompSelect('third')
            sel.needed = True
            sel.description = _('third')
            sel.set_location(1, 0)
            owner_third_ids = []
            for owner in Owner.objects.all():
                owner_third_ids.append(owner.third_id)
            items = Third.objects.filter(
                accountthird__code__regex=current_system_account(
                ).get_societary_mask()).exclude(
                    id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: str(t))
            sel.set_select_query(items)
            xfer.add_component(sel)
            btn = XferCompButton('add_third')
            btn.set_location(3, 0)
            btn.set_is_mini(True)
            btn.set_action(xfer.request,
                           ActionsManage.get_action_url(
                               'accounting.Third', 'Add', xfer),
                           close=CLOSE_NO,
                           modal=FORMTYPE_MODAL,
                           params={'new_account': ';'.join(new_account)})
            xfer.add_component(btn)
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
        else:
            old_item = xfer.item
            xfer.item = old_item.third.contact.get_final_child()
            xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item.third.get_final_child()
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
Exemplo n.º 9
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     dlg.get_components('activity').colspan = 3
     dlg.get_components('date').colspan = 3
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"),
                    close=CLOSE_YES,
                    params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Exemplo n.º 10
0
    def edit(self, xfer):
        if xfer.item.id is None:
            sel = XferCompSelect('third')
            sel.needed = True
            sel.description = _('third')
            sel.set_location(1, 0)
            owner_third_ids = []
            for owner in Owner.objects.all():
                owner_third_ids.append(owner.third_id)
            items = Third.objects.all().exclude(
                id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: six.text_type(t))
            sel.set_select_query(items)
            xfer.add_component(sel)
            btn = XferCompButton('add_third')
            btn.set_location(3, 0)
            btn.set_is_mini(True)
            btn.set_action(
                xfer.request,
                ActionsManage.get_action_url('accounting.Third', 'Add', xfer),
                close=CLOSE_NO,
                modal=FORMTYPE_MODAL,
                params={
                    'new_account':
                    Params.getvalue('condominium-default-owner-account')
                })
            xfer.add_component(btn)
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
        else:
            old_item = xfer.item
            xfer.item = old_item.third.contact.get_final_child()
            xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item.third.get_final_child()
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
Exemplo n.º 11
0
 def fillresponse(self, journal=0):
     if self.getparam('SAVE') is None:
         dlg = self.create_custom()
         image = XferCompImage('image')
         image.set_value(self.icon_path())
         image.set_location(0, 0, 1, 6)
         dlg.add_component(image)
         lbl = XferCompLabelForm('lblmodel')
         lbl.set_value(_('model name'))
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         if journal > 0:
             mod_query = ModelEntry.objects.filter(journal=journal)
         else:
             mod_query = ModelEntry.objects.all()
         sel = XferCompSelect('model')
         sel.set_location(2, 0)
         sel.set_needed(True)
         sel.set_select_query(mod_query)
         dlg.add_component(sel)
         lbl = XferCompLabelForm('lblfactor')
         lbl.set_value(_('factor'))
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         fact = XferCompFloat('factor', 0.00, 1000000.0, 2)
         fact.set_value(1.0)
         fact.set_location(2, 1)
         dlg.add_component(fact)
         dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"})
         dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     else:
         factor = self.getparam('factor', 1.0)
         model = ModelEntry.objects.get(id=self.getparam('model', 0))
         for old_key in ['SAVE', 'model', 'factor']:
             if old_key in self.params.keys():
                 del self.params[old_key]
         year = FiscalYear.get_current(self.getparam('year'))
         serial_entry = model.get_serial_entry(factor, year)
         date_value = date.today().isoformat()
         entry = EntryAccount.objects.create(year=year, date_value=date_value, designation=model.designation,
                                             journal=model.journal, costaccounting=model.costaccounting)
         entry.editor.before_save(self)
         self.params["entryaccount"] = entry.id
         self.redirect_action(EntryAccountEdit.get_action(), params={"serial_entry": serial_entry})
Exemplo n.º 12
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Exemplo n.º 13
0
 def _create_comp_foreignkey(self, field_name, dep_field):
     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)
     return comp
Exemplo n.º 14
0
    def fillresponse_header(self):
        status_filter = self.getparam('status_filter', -1)
        year_filter = self.getparam('year_filter', FiscalYear.get_current().id)
        lbl = XferCompLabelForm('lbl_statusfilter')
        lbl.set_value_as_name(_('Filter by status'))
        lbl.set_location(0, 1)
        self.add_component(lbl)
        dep_field = DepositSlip.get_field_by_name('status')
        sel_list = list(dep_field.choices)
        sel_list.insert(0, (-1, '---'))
        edt = XferCompSelect("status_filter")
        edt.set_select(sel_list)
        edt.set_value(status_filter)
        edt.set_needed(False)
        edt.set_location(1, 1)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)

        lbl = XferCompLabelForm('lbl_yearfilter')
        lbl.set_value_as_name(_('Filter by year'))
        lbl.set_location(0, 2)
        self.add_component(lbl)
        edt = XferCompSelect("year_filter")
        edt.set_needed(False)
        edt.set_select_query(FiscalYear.objects.all())
        edt.set_value(year_filter)
        edt.set_location(1, 2)
        edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(edt)

        self.filter = Q()
        if status_filter >= 0:
            self.filter &= Q(status=status_filter)
        if year_filter > 0:
            year = FiscalYear.objects.get(id=year_filter)
            self.filter &= Q(date__gte=year.begin)
            self.filter &= Q(date__lte=year.end)
Exemplo n.º 15
0
    def fill_header(self):
        self.item = FiscalYear.get_current(self.getparam("year"))
        new_begin = convert_date(self.getparam("begin"), self.item.begin)
        new_end = convert_date(self.getparam("end"), self.item.end)
        if (new_begin >= self.item.begin) and (new_end <= self.item.end):
            self.item.begin = new_begin
            self.item.end = new_end
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 3)
        self.add_component(img)

        select_year = XferCompSelect(self.field_id)
        select_year.set_location(1, 0, 4)
        select_year.set_select_query(FiscalYear.objects.all())
        select_year.set_value(self.item.id)
        select_year.set_needed(True)
        select_year.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(select_year)
        self.filter = Q(entry__year=self.item)
        if self.item.status != 2:
            self.fill_from_model(1, 1, False, ['begin'])
            self.fill_from_model(3, 1, False, ['end'])
            begin_filter = self.get_components('begin')
            begin_filter.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
            end_filter = self.get_components('end')
            end_filter.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
            self.filter &= Q(entry__date_value__gte=self.item.begin)
            self.filter &= Q(entry__date_value__lte=self.item.end)
        self.fill_filterCode()
        lbl = XferCompLabelForm("result")
        lbl.set_value_center(self.item.total_result_text)
        lbl.set_location(0, 6, 6)
        self.add_component(lbl)
        self.fill_filterheader()
        self.define_gridheader()
Exemplo n.º 16
0
    def fillresponse(self, season):
        if season is None:
            working_season = Season.current_season()
        else:
            working_season = Season.objects.get(id=season)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0)
        self.add_component(img)
        lab = XferCompLabelForm('lbl_season')
        lab.set_value_as_name(_('season'))
        lab.set_location(1, 0)
        self.add_component(lab)
        sel = XferCompSelect('season')
        sel.set_needed(True)
        sel.set_select_query(Season.objects.all())
        sel.set_value(working_season.id)
        sel.set_location(2, 0)
        sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(sel)
        stat_result = working_season.get_statistic()
        if len(stat_result) == 0:
            lab = XferCompLabelForm('lbl_season')
            lab.set_color('red')
            lab.set_value_as_infocenter(_('no subscription!'))
            lab.set_location(1, 1, 2)
            self.add_component(lab)
        else:
            tab_iden = 0
            for stat_title, stat_city, stat_type in stat_result:
                tab_iden += 1
                if (len(stat_city) > 0) and (len(stat_type) > 0):
                    self.new_tab(stat_title)
                    lab = XferCompLabelForm("lbltown_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by city"))
                    lab.set_location(0, 1)
                    self.add_component(lab)
                    grid = XferCompGrid("town_%d" % tab_iden)
                    grid.add_header("city", _("city"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_city:
                        for stat_key in stat_val.keys():
                            grid.set_value(cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 2)
                    self.add_component(grid)

                    lab = XferCompLabelForm("lbltype_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by type"))
                    lab.set_location(0, 3)
                    self.add_component(lab)
                    grid = XferCompGrid("type_%d" % tab_iden)
                    grid.add_header("type", _("type"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_type:
                        for stat_key in stat_val.keys():
                            if (stat_key == 'type') and not isinstance(stat_val['type'], six.text_type):
                                grid.set_value(cmp, stat_key, six.text_type(
                                    SubscriptionType.objects.get(id=stat_val['type'])))
                            else:
                                grid.set_value(
                                    cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 4)
                    self.add_component(grid)
        self.add_action(AdherentStatisticPrint.get_action(TITLE_PRINT, "images/print.png"),
                        close=CLOSE_NO, params={'classname': self.__class__.__name__})
        self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 17
0
 def fillresponse(self, AdhCmd=0):
     cmd_manager = CommandManager(self.getparam('CMD_FILE', ''), self.items)
     if self.getparam('SAVE') is None:
         dlg = self.create_custom(self.model)
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 4)
         dlg.add_component(img)
         lab = XferCompLabelForm('lbl_title')
         lab.set_value_as_title(self.caption)
         lab.set_location(1, 0)
         dlg.add_component(lab)
         row = dlg.get_max_row() + 1
         cmd_item = cmd_manager.get(AdhCmd)
         cmd_item_txt = cmd_manager.get_txt(cmd_item)
         for fname, ftitle in cmd_manager.get_fields():
             lbl = XferCompLabelForm("lbl" + fname)
             lbl.set_value_as_name(ftitle)
             lbl.set_location(1, row)
             dlg.add_component(lbl)
             if fname == "type":
                 sel = XferCompSelect(fname)
                 sel.set_select_query(SubscriptionType.objects.all())
                 sel.set_value(cmd_item[fname])
                 sel.set_needed(True)
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             elif fname == "team":
                 sel = XferCompSelect(fname)
                 sel.set_select_query(Team.objects.all())
                 sel.set_value(cmd_item[fname][0])
                 sel.set_needed(True)
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             elif fname == "activity":
                 sel = XferCompSelect(fname)
                 sel.set_select_query(Activity.objects.all())
                 sel.set_value(cmd_item[fname][0])
                 sel.set_needed(True)
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             elif fname == "reduce":
                 sel = XferCompFloat(fname)
                 sel.set_value(cmd_item[fname])
                 sel.set_location(2, row)
                 dlg.add_component(sel)
             else:
                 lbl = XferCompLabelForm(fname)
                 lbl.set_value(cmd_item_txt[fname])
                 lbl.set_location(2, row)
                 dlg.add_component(lbl)
             row += 1
         dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
     else:
         cmd_item = cmd_manager.get(AdhCmd)
         cmd_item['type'] = self.getparam("type", cmd_item['type'])
         cmd_item['team'] = self.getparam("team", cmd_item['team'])
         cmd_item['activity'] = self.getparam("activity", cmd_item['activity'])
         cmd_item['reduce'] = self.getparam("reduce", cmd_item['reduce'])
         cmd_manager.set(AdhCmd, cmd_item)
Exemplo n.º 18
0
 def fillresponse(self, season):
     if season is None:
         working_season = Season.current_season()
     else:
         working_season = Season.objects.get(id=season)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     sel = XferCompSelect('season')
     sel.set_needed(True)
     sel.set_select_query(Season.objects.all())
     sel.set_value(working_season.id)
     sel.set_location(1, 0)
     sel.description = _('season')
     sel.set_action(self.request,
                    self.get_action('', ''),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(sel)
     stat_result = Degree.get_statistic(working_season)
     if len(stat_result) == 0:
         lab = XferCompLabelForm('lbl_season')
         lab.set_color('red')
         lab.set_value_as_infocenter(_('no degree!'))
         lab.set_location(1, 1, 2)
         self.add_component(lab)
     else:
         total = 0
         pos_y = 2
         for activity, sublist in stat_result:
             subtotal = 0
             if activity is not None:
                 lab = XferCompLabelForm("lblactivite_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(activity))
                 lab.set_location(0, pos_y, 3)
                 self.add_component(lab)
                 pos_y += 1
             for degree_name, val in sublist:
                 lab = XferCompLabelForm("title_%d" % pos_y)
                 lab.set_value(degree_name)
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("val_%d" % pos_y)
                 lab.set_value(six.text_type(val))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 subtotal += val
                 total += val
                 pos_y += 1
             if activity is not None:
                 lab = XferCompLabelForm("lblsubtotal_%d" % activity.id)
                 lab.set_value_as_header(_("Total"))
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("subtotal_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(subtotal))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 pos_y += 1
         lab = XferCompLabelForm("lbltotal")
         lab.set_value_as_headername(_("Total"))
         lab.set_location(1, pos_y)
         self.add_component(lab)
         lab = XferCompLabelForm("total")
         lab.set_value_as_name(six.text_type(total))
         lab.set_location(2, pos_y)
         self.add_component(lab)
     self.add_action(DegreeStatisticPrint.get_action(
         TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO,
                     params={'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 19
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
Exemplo n.º 20
0
 def get_writing_comp(self, field_name):
     def get_value_from_field(default):
         val = getattr(self.item, field_name)
         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
     from django.core.exceptions import ObjectDoesNotExist
     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, field_name + '_query')
         else:
             sub_select = dep_field.remote_field.model.objects.all()
         comp.set_needed(not dep_field.null)
         comp.set_select_query(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)
     comp.description = six.text_type(dep_field.verbose_name)
     return comp
Exemplo n.º 21
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
Exemplo n.º 22
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)
Exemplo n.º 23
0
 def fillresponse(self, season):
     if season is None:
         working_season = Season.current_season()
     else:
         working_season = Season.objects.get(id=season)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lab = XferCompLabelForm('lbl_season')
     lab.set_value_as_name(_('season'))
     lab.set_location(1, 0)
     self.add_component(lab)
     sel = XferCompSelect('season')
     sel.set_needed(True)
     sel.set_select_query(Season.objects.all())
     sel.set_value(working_season.id)
     sel.set_location(2, 0)
     sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(sel)
     stat_result = Degree.get_statistic(working_season)
     if len(stat_result) == 0:
         lab = XferCompLabelForm('lbl_season')
         lab.set_color('red')
         lab.set_value_as_infocenter(_('no degree!'))
         lab.set_location(1, 1, 2)
         self.add_component(lab)
     else:
         total = 0
         pos_y = 2
         for activity, sublist in stat_result:
             subtotal = 0
             if activity is not None:
                 lab = XferCompLabelForm("lblactivite_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(activity))
                 lab.set_location(0, pos_y, 3)
                 self.add_component(lab)
                 pos_y += 1
             for degree_name, val in sublist:
                 lab = XferCompLabelForm("title_%d" % pos_y)
                 lab.set_value(degree_name)
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("val_%d" % pos_y)
                 lab.set_value(six.text_type(val))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 subtotal += val
                 total += val
                 pos_y += 1
             if activity is not None:
                 lab = XferCompLabelForm("lblsubtotal_%d" % activity.id)
                 lab.set_value_as_header(_("Total"))
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("subtotal_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(subtotal))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 pos_y += 1
         lab = XferCompLabelForm("lbltotal")
         lab.set_value_as_headername(_("Total"))
         lab.set_location(1, pos_y)
         self.add_component(lab)
         lab = XferCompLabelForm("total")
         lab.set_value_as_name(six.text_type(total))
         lab.set_location(2, pos_y)
         self.add_component(lab)
     self.add_action(DegreeStatisticPrint.get_action(TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO, params={'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))