Exemplo n.º 1
0
def editContact(request, id):
    contact = Contact.objects.get(id=id)
    formCont = ContactForm(request.POST or None, instance=contact)
    if formCont.is_valid():
        formCont.save()
        error(request, 'Информация о контакте успешно изменена.')
        return redirect('client-contact-index')
    var = {'contact': contact, 'formCont': formCont}

    return render_to_response('client/contact/edit.html', var, context_instance=RequestContext(request))
Exemplo n.º 2
0
  if request.method == 'POST' and settings.WORKFLOWMAX_APIKEY and settings.WORKFLOWMAX_ACCOUNTKEY:
    client.wm_delete()
  
  return delete_object(request, object_id=client.id, model=Client, login_required=True, template_name='client/delete.html', post_delete_redirect=reverse('client-list'), extra_context={'header': capfirst(_('delete client')), 'comment': capfirst(_('you are trying to delete client "%s". Sure?') % client.name)})

@login_required
def add_contact(request, object_id):
  context_vars = dict()
  try:
    object_id = int(object_id)
    client = Client.objects.get(id=object_id)
  except ValueError, ObjectDoesNotExist:
    return HttpResponseRedirect(reverse('client-list'))

  form = ContactForm()
  helper = FormHelper()
  submit = Submit('save',_('save'))
  helper.add_input(submit)
  
  if request.method == "POST":
    form = ContactForm(request.POST, request.FILES)
    if form.is_valid():
      contact = form.save(commit=False)
      contact.client = client
      contact.save()
      if settings.WORKFLOWMAX_APIKEY and settings.WORKFLOWMAX_ACCOUNTKEY:
        contact.wm_sync()
      messages.success(request, capfirst(_('contact was added successfully')), fail_silently=True)
      return HttpResponseRedirect(reverse('client-view', args=[client.id]))