コード例 #1
0
ファイル: forms.py プロジェクト: esauro/SingularMS
 def save(self, commit=True):
     instanceditemCommand = super(commandForm, self).save(commit=False)
     instanceditemCommand.type = 2
     instanceditemCommand.defaultAnswer = Body() #debugging                    
     channel = Channel.objects.get(pk=self.cleaned_data['channel'])
     for adminType in ADMIN_COMMAND_LIST_CHOICES:
         try:
             translatedCommandType = ADMIN_COMMAND_TRANSLATION[self.language][adminType[1] ]
         except KeyError:
             translatedCommandType = adminType[1]
              
         pattern = translatedCommandType + ASCII_SPACE + channel.name
         instanceditemCommand.pattern = pattern            
         #if instanceditemCommand.pattern is pattern:
             # Treating the instancied command
          #   continue            
         # Creating new one
         try:
             newCommand = Command.objects.get(pattern=pattern)
         except Command.DoesNotExist:
             newCommand = Command(pattern=pattern)
         except MultipleObjects:
             pass
         newCommand = copy.copy(instanceditemCommand)                
         newCommand.save()
     # return instanceditemCommand
     return None
コード例 #2
0
    def setUp(self):
        self.admin_name = 'proveedorBase'
        self.admin_pass = '******'
        
        self.customer_name = 'clienteBase'
        self.customer_pass = '******'
        
        self.account_name = 'cuentaBase'
        self.account_name2 = 'cuentaNoPurchase'
        self.account_name3 = 'cuentaVariosPurchase'
        
        self.purchase_id = 1        

        acc = Account.objects.get(name = self.account_name)
       
        cmd = Command(pattern = 'CANDELARIA AVISO', type = REPLY, active = True,
                      account = acc, priority = 0)
        cmd.save()
        body = Body(plainTxt = 'DUMMY ENCODE')
        body.save()
        rep = ReplyCommand(command = cmd, answer = body)
        rep.save()