コード例 #1
0
ファイル: views.py プロジェクト: ClareCat/liquid
def companies_new(request):
   message = ""
   if request.method == 'POST': # If the form has been submitted...
      e = Company()
      form = CompanyForm(request.POST,instance=e) # A form bound to the POST data
      if form.is_valid(): # All validation rules pass
          try:
              company = form.save(commit=False)
              company.username = slugify("rp14 "+company.company_name)
              company.save()
              messages.add_message(request, messages.SUCCESS, 'Company created (%s)'%(company.username))
              return HttpResponseRedirect('/intranet/jobfair_manager/companies') # Redirect after POST
          except IntegrityError as error:
              messages.add_message(request, messages.ERROR, "There is already a username like that! Please enter a different company name.")
   else:
      form = CompanyForm() # An unbound form

   return render_to_response('intranet/jobfair_manager/company_form.html',{
      'form': form,
      "section":"intranet",
      "page":"jobfair",
      "sub_page":"companies",
      "page_title":"Create new Company",
      "message": message
    },context_instance=RequestContext(request))
コード例 #2
0
ファイル: views.py プロジェクト: ClareCat/liquid
def companies_edit(request,id):
    e = Company.objects.get(id=id)
    if request.method == 'POST': # If the form has been submitted...
        form = CompanyForm(request.POST,instance=e) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Company changed')
            return HttpResponseRedirect('/intranet/jobfair_manager/companies') # Redirect after POST
    else:
        form = CompanyForm(instance=e)


    return render_to_response('intranet/jobfair_manager/company_form.html',{
        "form":form,
        "section":"intranet",
        "page":"jobfair",
        "sub_page":"companies",
        "page_title":"Edit Company",
        },context_instance=RequestContext(request))
コード例 #3
0
ファイル: views.py プロジェクト: pranaygp/liquid
def companies_new(request):
    message = ""
    if request.method == 'POST':  # If the form has been submitted...
        e = Company()
        form = CompanyForm(request.POST,
                           instance=e)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            try:
                company = form.save(commit=False)
                company.username = slugify("rp16 " + company.company_name)
                company.save()
                messages.add_message(
                    request, messages.SUCCESS,
                    'Company created (%s)' % (company.username))
                return HttpResponseRedirect(
                    '/intranet/jobfair_manager/companies'
                )  # Redirect after POST
            except IntegrityError as error:
                messages.add_message(
                    request, messages.ERROR,
                    "There is already a username like that! Please enter a different company name."
                )
    else:
        form = CompanyForm()  # An unbound form

    return render_to_response('intranet/jobfair_manager/company_form.html', {
        'form': form,
        "section": "intranet",
        "page": "jobfair",
        "sub_page": "companies",
        "page_title": "Create new Company",
        "message": message
    },
                              context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: pranaygp/liquid
def companies_edit(request, id):
    e = Company.objects.get(id=id)
    if request.method == 'POST':  # If the form has been submitted...
        form = CompanyForm(request.POST,
                           instance=e)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Company changed')
            return HttpResponseRedirect(
                '/intranet/jobfair_manager/companies')  # Redirect after POST
    else:
        form = CompanyForm(instance=e)

    return render_to_response('intranet/jobfair_manager/company_form.html', {
        "form": form,
        "section": "intranet",
        "page": "jobfair",
        "sub_page": "companies",
        "page_title": "Edit Company",
    },
                              context_instance=RequestContext(request))