events

package
v0.0.0-...-6dfde0d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RTNone  RSVPType = ""
	RTGoing          = "going"
	RTMaybe          = "maybe"
	RTHost           = "host"
)
View Source
const (
	STNone SubscriberType = ""
	STUser                = "user"
	STOrg                 = "organization"
)

Variables

View Source
var (
	ErrScanRSVPType       = errors.New("Error scanning RSVP Type")
	ErrScanSubscriberType = errors.New("Error scanning Subscriber Type")
	ErrStartDate          = errors.New("Invalid start date")
	ErrEndDate            = errors.New("Invalid end date")
	ErrEventsNotFound     = errors.New("Couldn't find any events for this search")
)

Functions

Types

type CreatorBinding

type CreatorBinding struct {
	Title     string `json:"title" form:"title" binding:"required"`
	StartDate string `json:"start_date" form:"start_date" binding:"required"`
	EndDate   string `json:"end_date" form:"end_date" binding:"required"`
	Location  string `json:"location" form:"location"`
	Summary   string `json:"summary" form:"summary"`
}

type Event

type Event struct {
	ID            string               `json:"id" gorm:"primary_key" sql:"type:uuid;default:uuid_generate_v4()"`
	Title         string               `json:"title"`
	StartDate     time.Time            `json:"start_date"`
	EndDate       time.Time            `json:"end_date"`
	Latitude      float64              `json:"latitude"`
	Longitude     float64              `json:"longitude"`
	Location      string               `json:"location"`
	PoliticalMap  matcher.PoliticalMap `json:"-" sql:"type:varchar(255)"`
	CenterX       int                  `json:"-"`
	CenterY       int                  `json:"-"`
	Summary       string               `json:"summary"`
	CoverPhotoURL string               `json:"cover_photo_url"`
	CreatedAt     time.Time            `json:"created_at"`
	UpdatedAt     time.Time            `json:"updated_at"`

	Hosts      []Subscriber `json:"hosts" sql:"-"`
	GoingCount int          `json:"going_count" sql:"-"`
	MaybeCount int          `json:"maybe_count" sql:"-"`
	Match      float64      `json:"match" sql:"-"`
	RSVP       RSVPType     `json:"rsvp" sql:"-"`
}

func GetByID

func GetByID(id string, guest Subscriber, db *gorm.DB) (e Event, err error)

func (*Event) AttachCoverPhoto

func (e *Event) AttachCoverPhoto(f multipart.File) error

func (Event) CanDelete

func (e Event) CanDelete(host Subscriber) bool

func (Event) CanUpdate

func (e Event) CanUpdate(host Subscriber) bool

func (*Event) CountGuests

func (e *Event) CountGuests(db *gorm.DB) error

func (Event) GetHostSubscriptions

func (e Event) GetHostSubscriptions(db *gorm.DB) (subs EventSubscriptions, err error)

func (*Event) GetHosts

func (e *Event) GetHosts(db *gorm.DB) error

func (*Event) GetLocation

func (e *Event) GetLocation(address string) error

GetLocation finds the latitude/longitude by postal code

func (*Event) GetMatch

func (e *Event) GetMatch(guest Subscriber) error

func (*Event) GetRSVP

func (e *Event) GetRSVP(guest Subscriber, db *gorm.DB) error

func (Event) GetSubscription

func (e Event) GetSubscription(guest Subscriber, db *gorm.DB) (s EventSubscription, err error)

func (Event) HasHost

func (e Event) HasHost(host Subscriber) bool

func (*Event) NewGuest

func (e *Event) NewGuest(guest Subscriber, rsvp RSVPType) (s EventSubscription, errs models.ValidationErrors)

func (*Event) NewHost

func (e *Event) NewHost(host Subscriber) (s EventSubscription, errs models.ValidationErrors)

func (*Event) Update

func (e *Event) Update(b UpdaterBinding) (errs models.ValidationErrors)

func (Event) Validate

func (e Event) Validate() (errs models.ValidationErrors)

type EventSubscription

type EventSubscription struct {
	ID             string    `json:"id" gorm:"primary_key" sql:"type:uuid;default:uuid_generate_v4()"`
	SubscriberType string    `json:"-"`
	SubscriberID   string    `json:"-" sql:"type:uuid"`
	EventID        string    `json:"event_id" sql:"type:uuid"`
	RSVP           RSVPType  `json:"rsvp"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`

	Subscriber Subscriber `json:"subscriber" sql:"-"`
}

type EventSubscriptions

type EventSubscriptions []EventSubscription

func (*EventSubscriptions) CollectSubscribers

func (subs *EventSubscriptions) CollectSubscribers(db *gorm.DB) error

func (EventSubscriptions) GetOrgIDs

func (subs EventSubscriptions) GetOrgIDs() (ids []string)

func (EventSubscriptions) GetUserIDs

func (subs EventSubscriptions) GetUserIDs() (ids []string)

type Events

type Events []Event

func GetByGuest

func GetByGuest(guest Subscriber, offset int, db *gorm.DB) (es Events, err error)

func GetByHost

func GetByHost(host Subscriber, offset int, db *gorm.DB) (es Events, err error)

func GetPastByGuest

func GetPastByGuest(guest Subscriber, offset int, db *gorm.DB) (es Events, err error)

func SearchForUser

func SearchForUser(u users.User, offset int, db *gorm.DB) (es Events, err error)

func (*Events) CollectHosts

func (es *Events) CollectHosts(db *gorm.DB) error

func (*Events) CollectMatches

func (es *Events) CollectMatches(guest Subscriber)

func (*Events) CollectRSVPs

func (es *Events) CollectRSVPs(guest Subscriber, db *gorm.DB) error

func (*Events) CountGuests

func (es *Events) CountGuests(db *gorm.DB) error

type RSVPType

type RSVPType string

func (*RSVPType) Scan

func (r *RSVPType) Scan(src interface{}) error

func (RSVPType) Value

func (s RSVPType) Value() (driver.Value, error)

type Subscriber

type Subscriber interface {
	GetID() string
	GetSubscriberType() string
	GetPoliticalMap() matcher.PoliticalMap
}

type SubscriberType

type SubscriberType string

func (*SubscriberType) Scan

func (s *SubscriberType) Scan(src interface{}) error

func (SubscriberType) Value

func (s SubscriberType) Value() (driver.Value, error)

type UpdaterBinding

type UpdaterBinding struct {
	Title     string `json:"title" form:"title" binding:"required"`
	StartDate string `json:"start_date" form:"start_date"`
	EndDate   string `json:"end_date" form:"end_date"`
	Location  string `json:"location" form:"location"`
	Summary   string `json:"summary" form:"summary"`
}

Jump to

Keyboard shortcuts

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