def create(request):
    """Render a form to create an entrepreneur."""
    
    if request.method == "POST":
        
        user_form = UserForm(request.POST)
        startup_form = StartupForm(request.POST,  request.FILES)
        
        if user_form.is_valid() and startup_form.is_valid():
            user = user_form.save()
            startup = startup_form.save()
            
            person = Person()
            entrepreneur = Entrepreneur()
            
            person.user = user
            person.save()
            
            entrepreneur.person = person
            entrepreneur.startup = startup
            entrepreneur.save()
            
            msg = _("Your user and startup has been created successfully.")
            
            return render_to_response("entrepreneurs/create.html",
                {
                "msg": msg,
                "user": user,
                },
                context_instance=RequestContext(request)
            )

        else:
            return render_to_response("entrepreneurs/create.html",
                {
                    "user_form": user_form,
                    "startup_form": startup_form,
                },
                context_instance=RequestContext(request)
            )
        
    else:
        return render_to_response("entrepreneurs/create.html",
            {
                "user_form": UserForm(),
                "startup_form": StartupForm(),
            },
            context_instance=RequestContext(request)
        )
Beispiel #2
0
def create(request):
    """Render a form to create an entrepreneur."""

    if request.method == "POST":

        user_form = UserForm(request.POST)
        startup_form = StartupForm(request.POST, request.FILES)

        if user_form.is_valid() and startup_form.is_valid():
            user = user_form.save()
            startup = startup_form.save()

            person = Person()
            entrepreneur = Entrepreneur()

            person.user = user
            person.save()

            entrepreneur.person = person
            entrepreneur.startup = startup
            entrepreneur.save()

            msg = _("Your user and startup has been created successfully.")

            return render_to_response("entrepreneurs/create.html", {
                "msg": msg,
                "user": user,
            },
                                      context_instance=RequestContext(request))

        else:
            return render_to_response("entrepreneurs/create.html", {
                "user_form": user_form,
                "startup_form": startup_form,
            },
                                      context_instance=RequestContext(request))

    else:
        return render_to_response("entrepreneurs/create.html", {
            "user_form": UserForm(),
            "startup_form": StartupForm(),
        },
                                  context_instance=RequestContext(request))
Beispiel #3
0
def create(request):
    """Render a form to create a mentor."""

    if request.method == "POST":

        user_form = UserForm(request.POST)
        mentor_form = MentorForm(request.POST)

        if user_form.is_valid() and mentor_form.is_valid():
            user = user_form.save()

            person = Person()
            mentor = mentor_form.save(commit=False)

            person.user = user
            person.save()

            mentor.person = person
            mentor.save()

            msg = _("Your user has been created successfully.")

            return render_to_response("mentors/create.html", {
                "msg": msg,
                "user": user,
            },
                                      context_instance=RequestContext(request))
        else:
            return render_to_response("mentors/create.html", {
                "user_form": user_form,
                "mentor_form": mentor_form,
            },
                                      context_instance=RequestContext(request))

    else:
        return render_to_response("mentors/create.html", {
            "user_form": UserForm(),
            "mentor_form": MentorForm(),
        },
                                  context_instance=RequestContext(request))