1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-04 21:15:24 +02:00

Enable custom logo upload and rendering

This commit is contained in:
McMatts 2019-01-06 13:50:12 +00:00
parent a211ba051a
commit 036f36ba1d
36 changed files with 574 additions and 211 deletions

View file

@ -99,6 +99,9 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
var sp space.Space
sp.Name = model.Name
sp.Description = model.Description
sp.Icon = model.Icon
sp.LabelID = model.LabelID
sp.RefID = uniqueid.Generate()
sp.OrgID = ctx.OrgID
sp.UserID = ctx.UserID
@ -675,52 +678,52 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
ok := true
ctx.Transaction, ok = h.Runtime.StartTx()
if !ok {
if !ok {
response.WriteError(w, method)
return
}
_, err := h.Store.Document.DeleteBySpace(ctx, id)
if err != nil {
h.Runtime.Rollback(ctx.Transaction)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
return
}
_, err = h.Store.Permission.DeleteSpacePermissions(ctx, id)
if err != nil {
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
return
}
// remove category permissions
_, err = h.Store.Permission.DeleteSpaceCategoryPermissions(ctx, id)
if err != nil {
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
return
}
_, err = h.Store.Pin.DeletePinnedSpace(ctx, id)
if err != nil && err != sql.ErrNoRows {
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
return
}
// remove category and members for space
_, err = h.Store.Category.DeleteBySpace(ctx, id)
if err != nil {
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
return
}
_, err = h.Store.Space.Delete(ctx, id)
if err != nil {
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
return
}
@ -728,22 +731,22 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
h.Runtime.Commit(ctx.Transaction)
// Record this action.
ctx.Transaction, ok = h.Runtime.StartTx()
if !ok {
response.WriteError(w, method)
return
}
ctx.Transaction, ok = h.Runtime.StartTx()
if !ok {
response.WriteError(w, method)
return
}
err = h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
SpaceID: id,
SourceType: activity.SourceTypeSpace,
ActivityType: activity.TypeDeleted})
if err != nil {
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
h.Runtime.Rollback(ctx.Transaction)
response.WriteServerError(w, method, err)
}
h.Runtime.Commit(ctx.Transaction)
h.Runtime.Commit(ctx.Transaction)
h.Store.Audit.Record(ctx, audit.EventTypeSpaceDelete)

View file

@ -30,7 +30,12 @@ type Store struct {
// Add adds new folder into the store.
func (s Store) Add(ctx domain.RequestContext, sp space.Space) (err error) {
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_space (c_refid, c_name, c_orgid, c_userid, c_type, c_lifecycle, c_likes, c_icon, c_desc, c_count_category, c_count_content, c_labelid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),
_, err = ctx.Transaction.Exec(s.Bind(`
INSERT INTO dmz_space
(c_refid, c_name, c_orgid, c_userid, c_type, c_lifecycle,
c_likes, c_icon, c_desc, c_count_category, c_count_content,
c_labelid, c_created, c_revised)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`),
sp.RefID, sp.Name, sp.OrgID, sp.UserID, sp.Type, sp.Lifecycle, sp.Likes,
sp.Icon, sp.Description, sp.CountCategory, sp.CountContent, sp.LabelID,
sp.Created, sp.Revised)