Exemplo n.º 1
0
func (cr *PublicationsApiController) UpdateMany(cx *goweb.Context) {
	if NotLoggedIn(cx) {
		cx.RespondWithStatus(UNAUTHORISED_HTTP_STATUS)
		return
	}
	cx.RespondWithOK()
}
Exemplo n.º 2
0
func (cr *PublicationsApiController) DeleteMany(cx *goweb.Context) {
	if NotLoggedIn(cx) {
		cx.RespondWithStatus(UNAUTHORISED_HTTP_STATUS)
		return
	}
	cx.RespondWithStatus(http.StatusForbidden)
}
Exemplo n.º 3
0
func UserName(cx *goweb.Context) {
	c := appengine.NewContext(cx.Request)
	u := user.Current(c)
	if u != nil {
		cx.RespondWithData(u.String())
	} else {
		cx.RespondWithData("")
	}
}
Exemplo n.º 4
0
func (cr *PublicationsApiController) Delete(id string, cx *goweb.Context) {
	if NotLoggedIn(cx) {
		cx.RespondWithStatus(UNAUTHORISED_HTTP_STATUS)
		return
	}
	c := appengine.NewContext(cx.Request)
	intID, err := strconv.Atoi(id)
	if err != nil {
		c.Infof("Invalid key while deleting: key = %v", id)
		return
	}
	pubs := model.PubsDAO.DeletePublication(int64(intID), c)
	cx.RespondWithData(pubs)
}
Exemplo n.º 5
0
func LoginLogoutURLs(cx *goweb.Context) {
	c := appengine.NewContext(cx.Request)
	loginURL, err := user.LoginURL(c, "/")
	if err != nil {
		cx.RespondWithStatus(400)
		return
	}
	logoutURL, err := user.LogoutURL(c, "/")
	if err != nil {
		cx.RespondWithStatus(400)
		return
	}
	cx.RespondWithData(URLs{loginURL, logoutURL})
}
Exemplo n.º 6
0
func (cr *PublicationsApiController) Create(cx *goweb.Context) {
	if NotLoggedIn(cx) {
		cx.RespondWithStatus(UNAUTHORISED_HTTP_STATUS)
		return
	}
	c := appengine.NewContext(cx.Request)
	var pub model.Publication
	// Create an object from POST request
	err := cx.Fill(&pub)
	if err != nil {
		c.Errorf("Form-decoder: %v", err)
		return
	}

	pubs := model.PubsDAO.CreatePublication(pub, c)
	cx.RespondWithData(pubs)
}
Exemplo n.º 7
0
func (cr *PublicationsApiController) ReadMany(cx *goweb.Context) {
	c := appengine.NewContext(cx.Request)
	pubs := model.PubsDAO.GetPublications(c)
	cx.RespondWithData(pubs)
}
Exemplo n.º 8
0
func (cr *PublicationsApiController) Read(id string, cx *goweb.Context) {
	cx.RespondWithOK()
}