gallery

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

README

import "github.com/coralproject/shelf/internal/ask/form/gallery"

Overview

Index

Package files

gallery.go

Constants

const Collection = "form_galleries"

Collection is the mongo collection where Gallery documents are saved.

Variables

var ErrInvalidID = errors.New("ID is not in it's proper form")

ErrInvalidID occurs when an ID is not in a valid form.

func Create

func Create(context interface{}, db *db.DB, gallery *Gallery) error

Create adds a form gallery based on the form id provided into the MongoDB database collection.

func Delete

func Delete(context interface{}, db *db.DB, id string) error

Delete removes the given Gallery with the ID provided.

func List

func List(context interface{}, db *db.DB, formID string) ([]Gallery, error)

List retrives the form galleries for a given form from the MongoDB database collection.

func Update

func Update(context interface{}, db *db.DB, id string, gallery *Gallery) error

Update updates the form gallery in the MongoDB database collection.

type Answer

type Answer struct {
    SubmissionID    bson.ObjectId       `json:"submission_id" bson:"submission_id" validate:"required"`
    AnswerID        string              `json:"answer_id" bson:"answer_id" validate:"required"`
    Answer          submission.Answer   `json:"answer,omitempty" bson:"-" validate:"-"`
    IdentityAnswers []submission.Answer `json:"identity_answers,omitempty" bson:"-"`
}

Answer describes an answer from a form which has been added to a Gallery.

func (*Answer) Validate
func (a *Answer) Validate() error

Validate checks the Anser value for consistency.

type Gallery struct {
    ID          bson.ObjectId          `json:"id" bson:"_id" validate:"required"`
    FormID      bson.ObjectId          `json:"form_id" bson:"form_id" validate:"required"`
    Headline    string                 `json:"headline" bson:"headline"`
    Description string                 `json:"description" bson:"description"`
    Config      map[string]interface{} `json:"config" bson:"config"`
    Answers     []Answer               `json:"answers" bson:"answers"`
    DateCreated time.Time              `json:"date_created,omitempty" bson:"date_created,omitempty"`
    DateUpdated time.Time              `json:"date_updated,omitempty" bson:"date_updated,omitempty"`
}

Gallery is a Form that has been moved to a shared space.

func AddAnswer
func AddAnswer(context interface{}, db *db.DB, id, submissionID, answerID string) (*Gallery, error)

AddAnswer adds an answer to a form gallery. Duplicated answers are de-duplicated automatically and will not return an error.

func RemoveAnswer
func RemoveAnswer(context interface{}, db *db.DB, id, submissionID, answerID string) (*Gallery, error)

RemoveAnswer adds an answer to a form gallery. Duplicated answers are de-duplicated automatically and will not return an error.

func Retrieve
func Retrieve(context interface{}, db *db.DB, id string) (*Gallery, error)

Retrieve retrieves a form gallery from the MongoDB database collection as well as hydrating the form gallery with form submissions.

func (fg *Gallery) Validate() error

Validate checks the Gallery value for consistency.


Generated by godoc2md

Documentation

Index

Constants

View Source
const Collection = "form_galleries"

Collection is the mongo collection where Gallery documents are saved.

Variables

View Source
var ErrInvalidID = errors.New("ID is not in it's proper form")

ErrInvalidID occurs when an ID is not in a valid form.

Functions

func Create

func Create(context interface{}, db *db.DB, gallery *Gallery) error

Create adds a form gallery based on the form id provided into the MongoDB database collection.

func Delete

func Delete(context interface{}, db *db.DB, id string) error

Delete removes the given Gallery with the ID provided.

func Update

func Update(context interface{}, db *db.DB, id string, gallery *Gallery) error

Update updates the form gallery in the MongoDB database collection.

Types

type Answer

type Answer struct {
	SubmissionID    bson.ObjectId       `json:"submission_id" bson:"submission_id" validate:"required"`
	AnswerID        string              `json:"answer_id" bson:"answer_id" validate:"required"`
	Answer          submission.Answer   `json:"answer,omitempty" bson:"-" validate:"-"`
	IdentityAnswers []submission.Answer `json:"identity_answers,omitempty" bson:"-"`
}

Answer describes an answer from a form which has been added to a Gallery.

func (*Answer) Validate

func (a *Answer) Validate() error

Validate checks the Anser value for consistency.

type Gallery struct {
	ID          bson.ObjectId          `json:"id" bson:"_id" validate:"required"`
	FormID      bson.ObjectId          `json:"form_id" bson:"form_id" validate:"required"`
	Headline    string                 `json:"headline" bson:"headline"`
	Description string                 `json:"description" bson:"description"`
	Config      map[string]interface{} `json:"config" bson:"config"`
	Answers     []Answer               `json:"answers" bson:"answers"`
	DateCreated time.Time              `json:"date_created,omitempty" bson:"date_created,omitempty"`
	DateUpdated time.Time              `json:"date_updated,omitempty" bson:"date_updated,omitempty"`
}

Gallery is a Form that has been moved to a shared space.

func AddAnswer

func AddAnswer(context interface{}, db *db.DB, id, submissionID, answerID string) (*Gallery, error)

AddAnswer adds an answer to a form gallery. Duplicated answers are de-duplicated automatically and will not return an error.

func List

func List(context interface{}, db *db.DB, formID string) ([]Gallery, error)

List retrives the form galleries for a given form from the MongoDB database collection.

func RemoveAnswer

func RemoveAnswer(context interface{}, db *db.DB, id, submissionID, answerID string) (*Gallery, error)

RemoveAnswer adds an answer to a form gallery. Duplicated answers are de-duplicated automatically and will not return an error.

func Retrieve

func Retrieve(context interface{}, db *db.DB, id string) (*Gallery, error)

Retrieve retrieves a form gallery from the MongoDB database collection as well as hydrating the form gallery with form submissions.

func (*Gallery) Validate

func (fg *Gallery) Validate() error

Validate checks the Gallery value for consistency.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL