Exemple #1
0
func TestResumeQuery(t *testing.T) {
	p := &models.Person{
		AboutMe: "rocket scientist",
	}
	err := Create(p)
	if err != nil {
		t.Error(err)
	}

	// Add a sample resumes
	for _, v := range []string{"one", "two", "three"} {
		resume := models.SampleResume()
		resume.Name = v

		//
		//	CreateResume
		//
		rerr := CreateResume(p, resume)
		if rerr != nil {
			t.Errorf("creating resume %v", rerr)
		}
	}

	//
	//	GetResumeByID
	//
	resume, err := GetResumeByID(p.Resumes[0].ID)
	if err != nil {
		t.Errorf("getting resume %v", err)
	}

	// check whether the ResumeBasic was loaded
	if resume.ResumeBasic.Name != "John Doe" {
		t.Errorf("expected Jon Doe got %s", resume.ResumeBasic.Name)
	}

	//
	//	GetAllPersonResumes
	//
	resumes, err := GetAllPersonResumes(p)
	if err != nil {
		t.Errorf("getting all erson resumes %v", err)
	}
	if len(resumes) != 3 {
		t.Errorf("expected 3 got %d instead", len(resumes))
	}
}
Exemple #2
0
// Create creates a new resume.
//
//		Method           POST
//
//		Route            /resume/new
//
//		Restrictions     Yes
//
// 		Template         None
func Create(ctx *echo.Context) error {
	var flashMessages = flash.New()
	r := ctx.Request()
	r.ParseForm()
	name := r.Form.Get("resume_name")

	user := ctx.Get("User").(*models.Person)

	resume := models.SampleResume()
	resume.Name = name
	err := query.CreateResume(user, resume)
	if err != nil {
		utils.SetData(ctx, "Message", tmpl.ServerErrorMessage)
		return ctx.Render(http.StatusInternalServerError, tmpl.ErrServerTpl, utils.GetData(ctx))
	}

	flashMessages.Success("successful created a new resume")
	flashMessages.Save(ctx)

	// Redirect to the update page for further updating of the resume.
	ctx.Redirect(http.StatusFound, fmt.Sprintf("/resume/update/%d", resume.ID))
	return nil
}