Exemplo n.º 1
0
 def fillresponse(self):
     self.fields_desc.initial(self.item)
     self.read_criteria_from_params()
     self.fillresponse_add_title()
     self.fillresponse_search_select()
     self.fillresponse_search_values()
     self.fillresponse_show_criteria()
     row = self.get_max_row()
     if isinstance(self.filter, Q) and (len(self.filter.children) > 0):
         self.items = self.model.objects.filter(
             self.filter)
     else:
         self.items = self.model.objects.all()
     grid = XferCompGrid(self.field_id)
     grid.set_model(self.items, self.fieldnames, self)
     grid.add_actions(self, action_list=self.action_grid)
     grid.set_location(0, row + 4, 4)
     grid.set_size(200, 500)
     self.add_component(grid)
     lbl = XferCompLabelForm("nb")
     lbl.set_location(0, row + 5, 4)
     lbl.set_value(_("Total number of %(name)s: %(count)d") % {
                   'name': self.model._meta.verbose_name_plural, 'count': grid.nb_lines})
     self.add_component(lbl)
     for act_type, title, icon in self.action_list:
         self.add_action(ActionsManage.get_act_changed(
             self.model.__name__, act_type, title, icon), {'close': CLOSE_NO})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Exemplo n.º 2
0
Arquivo: views.py Projeto: povtux/core
 def fillresponse(self, field_id):
     self.items = self.model.objects.filter(
         id__in=self.getparam(field_id, ()))
     if len(self.items) < 2:
         raise LucteriosException(
             IMPORTANT, _("Impossible: you must to select many records!"))
     if self.item.id is None:
         self.item = self.items[0]
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         grid = XferCompGrid(self.field_id)
         grid.add_header('value', _('designation'))
         grid.add_header('select', _('is main?'), 'bool')
         for item in self.items:
             grid.set_value(item.id, 'value', six.text_type(item))
             grid.set_value(item.id, 'select', item.id == self.item.id)
         grid.set_location(1, 1)
         grid.add_action(self.request, self.get_action(_("Edit"), "images/show.png"), {
                         'modal': FORMTYPE_MODAL, 'close': CLOSE_NO, 'unique': SELECT_SINGLE, 'params': {"CONFIRME": 'OPEN'}})
         grid.add_action(self.request, self.get_action(
             _("Select"), "images/ok.png"), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO, 'unique': SELECT_SINGLE})
         dlg.add_component(grid)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"),
                        {'close': CLOSE_YES, 'modal': FORMTYPE_MODAL, 'params': {'CONFIRME': 'YES', self.field_id: self.item.id}})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"), {})
     elif self.getparam("CONFIRME") == 'YES':
         alias_objects = []
         for item in self.items:
             if item.id != self.item.id:
                 alias_objects.append(item.get_final_child())
         self.item.get_final_child().merge_objects(alias_objects)
         self.redirect_action(ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {
                              'params': {field_id: self.item.id}})
     else:
         self.redirect_action(ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {
                              'params': {field_id: self.item.id}})
Exemplo n.º 3
0
 def fillresponse(self):
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0)
     self.add_component(lbl)
     self.fillresponse_header()
     self.fillresponse_body()
     if self.model is not None:
         for act_type, title, icon in self.action_list:
             self.add_action(ActionsManage.get_act_changed(
                 self.model.__name__, act_type, title, icon), {'close': CLOSE_NO})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Exemplo n.º 4
0
 def fillresponse(self):
     max_row = self.get_max_row() + 1
     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, max_row, True)
     for action_item in self.action_list:
         act_type, title, icon, close = action_item[:4]
         if len(action_item) > 4:
             params = action_item[4]
         else:
             params = {}
         self.add_action(ActionsManage.get_act_changed(
             self.model.__name__, act_type, title, icon), {'close': close, 'params': params})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Exemplo n.º 5
0
Arquivo: views.py Projeto: povtux/core
 def fillresponse(self):
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0)
         dlg.add_component(img)
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_record')
         lbl.set_value_as_name(_('record'))
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('record')
         lbl.set_value(six.text_type(self.item))
         lbl.set_location(2, 1)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_current')
         lbl.set_value_as_name(_('current model'))
         lbl.set_location(1, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current')
         lbl.set_value(self.item.__class__._meta.verbose_name)
         lbl.set_location(2, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_newmodel')
         lbl.set_value_as_name(_('new model'))
         lbl.set_location(1, 3)
         dlg.add_component(lbl)
         lbl = XferCompSelect('newmodel')
         lbl.set_select(self.item.__class__.get_select_contact_type(False))
         lbl.set_location(2, 3)
         dlg.add_component(lbl)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"),
                        {'close': CLOSE_YES, 'modal': FORMTYPE_MODAL, 'params': {'CONFIRME': 'YES'}})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"), {})
     else:
         new_model = apps.get_model(self.getparam('newmodel'))
         field_id_name = "%s_ptr_id" % self.model.__name__.lower()
         new_object = new_model(**{field_id_name: self.item.pk})
         new_object.save()
         new_object.__dict__.update(self.item.__dict__)
         new_object.save()
         self.redirect_action(
             ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {})
Exemplo n.º 6
0
 def fillresponse(self):
     if "SAVE" in self.params.keys():
         del self.params["SAVE"]
     if self.has_changed:
         self.item.editor.before_save(self)
         try:
             self.item.save()
             self.has_changed = False
             if self.fill_manytomany_fields():
                 self.item.save()
         except IntegrityError as err:
             getLogger("lucterios.core.container").info("%s", err)
             six.print_(err)
             self.raise_except(
                 _("This record exists yet!"), self.raise_except_class)
     if self.except_msg == '':
         self.item.editor.saving(self)
     if isinstance(self.redirect_to_show, six.text_type):
         self.redirect_action(ActionsManage.get_act_changed(
             self.model.__name__, self.redirect_to_show, '', ''), {'params': {self.field_id: self.item.id}})