Example #1
0
 def fillresponse(self, send_email=True):
     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, 2)
         dlg.add_component(lab)
         grid = XferCompGrid('AdhCmd')
         for fname, ftitle in cmd_manager.get_fields():
             grid.add_header(fname, ftitle)
         for cmd_id, cmd_item in cmd_manager.get_content_txt():
             for head_name, value in cmd_item.items():
                 grid.set_value(cmd_id, head_name, value)
         grid.set_location(1, 2, 2)
         grid.add_action(self.request, AdherentCommandModify.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         grid.add_action(self.request, AdherentCommandDelete.get_action(TITLE_DELETE, "images/delete.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         dlg.params['CMD_FILE'] = cmd_manager.file_name
         dlg.add_component(grid)
         if len(grid.records) > 0:
             lab = XferCompLabelForm('lbl_send_email')
             lab.set_value_as_name(_('Send quotition by email for each adherent.'))
             lab.set_location(1, 3)
             dlg.add_component(lab)
             chk = XferCompCheck('send_email')
             chk.set_value(send_email)
             chk.set_location(2, 3)
             dlg.add_component(chk)
             dlg.add_action(AdherentCommand.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
     else:
         dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref)
         if send_email:
             param_email = self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language
         else:
             param_email = None
         nb_sub, nb_bill = cmd_manager.create_subscription(dateref, param_email)
         if send_email:
             msg = _('%(nbsub)d new subscription and %(nbbill)d quotation have been sent.') % {'nbsub': nb_sub, 'nbbill': nb_bill}
         else:
             msg = _('%d new subscription have been prepared.') % nb_sub
         self.message(msg)
Example #2
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)