MCPcopy
hub / github.com/writefreely/writefreely / viewCollections

Function viewCollections

account.go:818–857  ·  view source on GitHub ↗
(app *App, u *User, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

816}
817
818func viewCollections(app *App, u *User, w http.ResponseWriter, r *http.Request) error {
819 c, err := app.db.GetCollections(u, app.cfg.App.Host)
820 if err != nil {
821 log.Error("unable to fetch collections: %v", err)
822 return fmt.Errorf("No collections")
823 }
824
825 f, _ := getSessionFlashes(app, w, r, nil)
826
827 uc, _ := app.db.GetUserCollectionCount(u.ID)
828 // TODO: handle any errors
829
830 silenced, err := app.db.IsUserSilenced(u.ID)
831 if err != nil {
832 if err == ErrUserNotFound {
833 return err
834 }
835 log.Error("view collections: %v", err)
836 return fmt.Errorf("view collections: %v", err)
837 }
838 d := struct {
839 *UserPage
840 Collections *[]Collection
841
842 UsedCollections, TotalCollections int
843
844 NewBlogsDisabled bool
845 Silenced bool
846 }{
847 UserPage: NewUserPage(app, r, u, u.Username+"'s Blogs", f),
848 Collections: c,
849 UsedCollections: int(uc),
850 NewBlogsDisabled: !app.cfg.App.CanCreateBlogs(uc),
851 Silenced: silenced,
852 }
853 d.UserPage.SetMessaging(u)
854 showUserPage(w, "collections", d)
855
856 return nil
857}
858
859func viewEditCollection(app *App, u *User, w http.ResponseWriter, r *http.Request) error {
860 vars := mux.Vars(r)

Callers

nothing calls this directly

Calls 8

getSessionFlashesFunction · 0.85
NewUserPageFunction · 0.85
showUserPageFunction · 0.85
IsUserSilencedMethod · 0.80
CanCreateBlogsMethod · 0.80
SetMessagingMethod · 0.80
GetCollectionsMethod · 0.65

Tested by

no test coverage detected