mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
Enable custom logo upload and rendering
This commit is contained in:
parent
a211ba051a
commit
036f36ba1d
36 changed files with 574 additions and 211 deletions
|
@ -46,7 +46,6 @@ import (
|
|||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/group"
|
||||
"github.com/documize/community/model/link"
|
||||
"github.com/documize/community/model/org"
|
||||
"github.com/documize/community/model/page"
|
||||
"github.com/documize/community/model/permission"
|
||||
"github.com/documize/community/model/pin"
|
||||
|
@ -231,14 +230,14 @@ func (b backerHandler) dmzOrg(files *[]backupItem) (err error) {
|
|||
w = fmt.Sprintf(" WHERE c_refid='%s' ", b.Spec.OrgID)
|
||||
}
|
||||
|
||||
o := []org.Organization{}
|
||||
o := []orgExtended{}
|
||||
err = b.Runtime.Db.Select(&o, `SELECT id, c_refid AS refid,
|
||||
c_title AS title, c_message AS message, c_domain AS domain,
|
||||
c_service AS conversionendpoint, c_email AS email, c_serial AS serial, c_active AS active,
|
||||
c_anonaccess AS allowanonymousaccess, c_authprovider AS authprovider,
|
||||
c_anonaccess AS allowanonymousaccess, c_authprovider AS authprovider,
|
||||
coalesce(c_sub,`+b.Runtime.StoreProvider.JSONEmpty()+`) AS subscription,
|
||||
coalesce(c_authconfig,`+b.Runtime.StoreProvider.JSONEmpty()+`) AS authconfig, c_maxtags AS maxtags,
|
||||
c_created AS created, c_revised AS revised
|
||||
c_theme AS theme, c_logo AS logo, c_created AS created, c_revised AS revised
|
||||
FROM dmz_org`+w)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -255,10 +254,6 @@ func (b backerHandler) dmzOrg(files *[]backupItem) (err error) {
|
|||
|
||||
// Config, User Config.
|
||||
func (b backerHandler) dmzConfig(files *[]backupItem) (err error) {
|
||||
type config struct {
|
||||
ConfigKey string `json:"key"`
|
||||
ConfigValue string `json:"config"`
|
||||
}
|
||||
c := []config{}
|
||||
err = b.Runtime.Db.Select(&c, `SELECT c_key AS configkey, c_config AS configvalue FROM dmz_config`)
|
||||
if err != nil {
|
||||
|
@ -279,14 +274,7 @@ func (b backerHandler) dmzConfig(files *[]backupItem) (err error) {
|
|||
w = fmt.Sprintf(" where c_orgid='%s' ", b.Spec.OrgID)
|
||||
}
|
||||
|
||||
type userConfig struct {
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
ConfigKey string `json:"key"`
|
||||
ConfigValue string `json:"config"`
|
||||
}
|
||||
uc := []userConfig{}
|
||||
|
||||
err = b.Runtime.Db.Select(&uc, `select c_orgid AS orgid, c_userid AS userid,
|
||||
c_key AS configkey, c_config AS configvalue FROM dmz_user_config`+w)
|
||||
if err != nil {
|
||||
|
@ -475,6 +463,8 @@ func (b backerHandler) dmzSpace(files *[]backupItem) (err error) {
|
|||
err = b.Runtime.Db.Select(&sp, `SELECT id, c_refid AS refid,
|
||||
c_name AS name, c_orgid AS orgid, c_userid AS userid,
|
||||
c_type AS type, c_lifecycle AS lifecycle, c_likes AS likes,
|
||||
c_icon AS icon, c_labelid AS labelid, c_desc AS description,
|
||||
c_count_category As countcategory, c_count_content AS countcontent,
|
||||
c_created AS created, c_revised AS revised
|
||||
FROM dmz_space`+w)
|
||||
if err != nil {
|
||||
|
@ -671,16 +661,6 @@ func (b backerHandler) dmzDocument(files *[]backupItem) (err error) {
|
|||
*files = append(*files, backupItem{Filename: "dmz_doc.json", Content: content})
|
||||
|
||||
// Vote
|
||||
type vote struct {
|
||||
RefID string `json:"refId"`
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
VoterID string `json:"voterId"`
|
||||
Vote int `json:"vote"`
|
||||
Created time.Time `json:"created"`
|
||||
Revised time.Time `json:"revised"`
|
||||
}
|
||||
|
||||
vt := []vote{}
|
||||
err = b.Runtime.Db.Select(&vt, `
|
||||
SELECT c_refid AS refid, c_orgid AS orgid,
|
||||
|
@ -716,16 +696,6 @@ func (b backerHandler) dmzDocument(files *[]backupItem) (err error) {
|
|||
*files = append(*files, backupItem{Filename: "dmz_doc_link.json", Content: content})
|
||||
|
||||
// Comment
|
||||
type comment struct {
|
||||
RefID string `json:"feedbackId"`
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
UserID string `json:"userId"`
|
||||
Email string `json:"email"`
|
||||
Feedback string `json:"feedback"`
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
|
||||
cm := []comment{}
|
||||
err = b.Runtime.Db.Select(&cm, `
|
||||
SELECT c_refid AS refid, c_orgid AS orgid, c_docid AS documentid,
|
||||
|
@ -743,20 +713,6 @@ func (b backerHandler) dmzDocument(files *[]backupItem) (err error) {
|
|||
*files = append(*files, backupItem{Filename: "dmz_doc_comment.json", Content: content})
|
||||
|
||||
// Share
|
||||
type share struct {
|
||||
ID uint64 `json:"id"`
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
Email string `json:"email"`
|
||||
Message string `json:"message"`
|
||||
Viewed string `json:"viewed"` // recording each view as |date-viewed|date-viewed|
|
||||
Secret string `json:"secret"` // secure token used to access document
|
||||
Expires string `json:"expires"` // number of days from creation, value of 0 means never
|
||||
Active bool `json:"active"`
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
|
||||
sh := []share{}
|
||||
err = b.Runtime.Db.Select(&sh, `
|
||||
SELECT id AS id, c_orgid AS orgid, c_docid AS documentid,
|
||||
|
|
78
domain/backup/models.go
Normal file
78
domain/backup/models.go
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
// Package backup handle data backup/restore to/from ZIP format.
|
||||
package backup
|
||||
|
||||
// Existing data models do not necessarily have fields to hold
|
||||
// all data when loaded from the database.
|
||||
// So we extend the existing models to hold additional fields
|
||||
// for a complete backup and restore process.
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/model/org"
|
||||
)
|
||||
|
||||
type orgExtended struct {
|
||||
org.Organization
|
||||
Logo []byte `json:"logo"`
|
||||
}
|
||||
|
||||
type config struct {
|
||||
ConfigKey string `json:"key"`
|
||||
ConfigValue string `json:"config"`
|
||||
}
|
||||
|
||||
type userConfig struct {
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
ConfigKey string `json:"key"`
|
||||
ConfigValue string `json:"config"`
|
||||
}
|
||||
|
||||
// Vote
|
||||
type vote struct {
|
||||
RefID string `json:"refId"`
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
VoterID string `json:"voterId"`
|
||||
Vote int `json:"vote"`
|
||||
Created time.Time `json:"created"`
|
||||
Revised time.Time `json:"revised"`
|
||||
}
|
||||
|
||||
// Comment
|
||||
type comment struct {
|
||||
RefID string `json:"feedbackId"`
|
||||
OrgID string `json:"orgId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
UserID string `json:"userId"`
|
||||
Email string `json:"email"`
|
||||
Feedback string `json:"feedback"`
|
||||
Created time.Time `json:"created"`
|
||||
}
|
||||
|
||||
// Share
|
||||
type share struct {
|
||||
ID uint64 `json:"id"`
|
||||
OrgID string `json:"orgId"`
|
||||
UserID string `json:"userId"`
|
||||
DocumentID string `json:"documentId"`
|
||||
Email string `json:"email"`
|
||||
Message string `json:"message"`
|
||||
Viewed string `json:"viewed"` // recording each view as |date-viewed|date-viewed|
|
||||
Secret string `json:"secret"` // secure token used to access document
|
||||
Expires string `json:"expires"` // number of days from creation, value of 0 means never
|
||||
Active bool `json:"active"`
|
||||
Created time.Time `json:"created"`
|
||||
}
|
|
@ -39,7 +39,6 @@ import (
|
|||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/group"
|
||||
"github.com/documize/community/model/link"
|
||||
"github.com/documize/community/model/org"
|
||||
"github.com/documize/community/model/page"
|
||||
"github.com/documize/community/model/permission"
|
||||
"github.com/documize/community/model/pin"
|
||||
|
@ -332,7 +331,7 @@ func (r *restoreHandler) readZip(filename string) (found bool, b []byte, err err
|
|||
func (r *restoreHandler) dmzOrg() (err error) {
|
||||
filename := "dmz_org.json"
|
||||
|
||||
org := []org.Organization{}
|
||||
org := []orgExtended{}
|
||||
err = r.fileJSON(filename, &org)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("failed to load %s", filename))
|
||||
|
@ -363,12 +362,14 @@ func (r *restoreHandler) dmzOrg() (err error) {
|
|||
_, err = r.Context.Transaction.Exec(r.Runtime.Db.Rebind(`
|
||||
INSERT INTO dmz_org (c_refid, c_company, c_title, c_message,
|
||||
c_domain, c_service, c_email, c_anonaccess, c_authprovider, c_authconfig,
|
||||
c_maxtags, c_verified, c_serial, c_sub, c_active, c_created, c_revised)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`),
|
||||
c_maxtags, c_verified, c_serial, c_sub, c_active,
|
||||
c_theme, c_logo, c_created, c_revised)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`),
|
||||
org[i].RefID, org[i].Company, org[i].Title, org[i].Message,
|
||||
strings.ToLower(org[i].Domain), org[i].ConversionEndpoint, strings.ToLower(org[i].Email),
|
||||
org[i].AllowAnonymousAccess, org[i].AuthProvider, org[i].AuthConfig,
|
||||
org[i].MaxTags, true, org[i].Serial, org[i].Subscription,
|
||||
org[i].Theme, org[i].Logo,
|
||||
org[i].Active, org[i].Created, org[i].Revised)
|
||||
if err != nil {
|
||||
r.Context.Transaction.Rollback()
|
||||
|
@ -402,6 +403,7 @@ func (r *restoreHandler) dmzOrg() (err error) {
|
|||
org[0].Serial = r.Spec.Org.Serial
|
||||
org[0].Title = r.Spec.Org.Title
|
||||
org[0].Subscription = r.Spec.Org.Subscription
|
||||
org[0].Theme = r.Spec.Org.Theme
|
||||
}
|
||||
|
||||
_, err = r.Context.Transaction.NamedExec(`UPDATE dmz_org SET
|
||||
|
@ -612,8 +614,16 @@ func (r *restoreHandler) dmzSpace() (err error) {
|
|||
}
|
||||
|
||||
for i := range sp {
|
||||
_, err = r.Context.Transaction.Exec(r.Runtime.Db.Rebind("INSERT INTO dmz_space (c_refid, c_name, c_orgid, c_userid, c_type, c_lifecycle, c_likes, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),
|
||||
sp[i].RefID, sp[i].Name, r.remapOrg(sp[i].OrgID), r.remapUser(sp[i].UserID), sp[i].Type, sp[i].Lifecycle, sp[i].Likes, sp[i].Created, sp[i].Revised)
|
||||
_, err = r.Context.Transaction.Exec(r.Runtime.Db.Rebind(`
|
||||
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[i].RefID, sp[i].Name, r.remapOrg(sp[i].OrgID),
|
||||
r.remapUser(sp[i].UserID), sp[i].Type, sp[i].Lifecycle,
|
||||
sp[i].Likes, sp[i].Icon, sp[i].Description, sp[i].CountCategory,
|
||||
sp[i].CountContent, sp[i].LabelID, sp[i].Created, sp[i].Revised)
|
||||
|
||||
if err != nil {
|
||||
r.Context.Transaction.Rollback()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue