Commit ccfc1466 authored by zauberstuhl's avatar zauberstuhl

Remove membership logic from aspect creation

parent 93c11fc8
......@@ -20,7 +20,7 @@ package controllers
import (
"github.com/revel/revel"
"gopkg.in/ganggo/ganggo.v0/app/models"
"strconv"
"errors"
)
type ApiAspect struct {
......@@ -100,41 +100,24 @@ func (a ApiAspect) Index() revel.Result {
}
func (a ApiAspect) Create() revel.Result {
name := a.Params.Get("name")
personID, err := strconv.ParseUint(
a.Params.Get("personID"), 0, 64)
if err != nil {
revel.AppLog.Error("Failed parsing uint :%s", err.Error())
return a.RenderError(err)
name := a.Params.Get("aspect_name")
if name == "" {
errMsg := "Aspect name seams to be empty"
revel.AppLog.Error(errMsg)
return a.RenderError(errors.New(errMsg))
}
revel.AppLog.Debug("params", name, personID)
user, err := models.GetCurrentUser(a.Session["TOKEN"])
if err != nil {
revel.AppLog.Error("Failed to get current user :%s", err.Error())
return a.RenderError(err)
}
var person models.Person
err = person.FindByID(uint(personID))
if err != nil {
revel.AppLog.Error("Failed finding person by id :%s", err.Error())
return a.RenderError(err)
}
aspect := models.Aspect{
Name: name,
UserID: user.ID,
Memberships: []models.AspectMembership{
models.AspectMembership{
PersonID: person.ID,
},
},
}
revel.AppLog.Debug("aspect", aspect)
err = aspect.Create()
if err != nil {
revel.AppLog.Error("Failed creating an aspect :%s", err.Error())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment