コード例 #1
0
ファイル: views.py プロジェクト: pombredanne/xscheduling
def add_client_contact(request, object_id):
  try:
    object_id = int(object_id)
  except ValueError:
    return HttpResponseRedirect(reverse('workflowmax-client-list'))
  context_vars = dict()
  context_vars['header'] = capfirst(_('add new contact for client %d') % object_id)
  form = ContactForm()
  helper = FormHelper()
  helper.form_class = 'uniform'
  submit = Submit('save',_('save'))
  helper.add_input(submit)
  if request.method == "POST":
    form = ContactForm(request.POST, request.FILES)
    if form.is_valid():
      contact = Contact()
      contact.owner_id = object_id
      contact.name = form.cleaned_data['name']
      contact.mobile = form.cleaned_data['mobile']
      contact.email = form.cleaned_data['email']
      contact.phone = form.cleaned_data['phone']
      contact.position = form.cleaned_data['position']
      contact = contact.save()
      return HttpResponseRedirect(reverse('workflowmax-client', args=[object_id]))
  
  context_vars['form'] = form
  context_vars['helper'] = helper
  return direct_to_template(request, template='workflowmax/form.html', extra_context=context_vars)
コード例 #2
0
ファイル: models.py プロジェクト: pombredanne/xscheduling
 def wm_sync(self):
   if self.name and self.client.wm_id:
     wm_contact = WorkflowmaxContact()
     if self.wm_id:
       wm_contact.id = int(self.wm_id)
     else:
       wm_contact.owner_id = int(self.client.wm_id)      
     wm_contact.name = self.name
     wm_contact.mobile = self.mobile
     wm_contact.email = self.email
     wm_contact.phone = self.phone
     wm_contact.position = self.position
     wm_contact = wm_contact.save()
     if not self.wm_id:
       self.wm_id = wm_contact.id
       self.save()