events

package
v0.0.0-...-d78814b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusInvited  = "invited"
	StatusGoing    = "going"
	StatusMaybe    = "maybe"
	StatusNotGoing = "not going"
)

RSVP status constants.

Variables

View Source
var DB *gorm.DB

DB is a reference to the parent app's gorm DB.

Functions

func UseDB

func UseDB(db *gorm.DB)

UseDB registers the DB from the root app.

Types

type ByDate

type ByDate []*Event

ByDate sorts events by their start time.

func (ByDate) Len

func (a ByDate) Len() int

func (ByDate) Less

func (a ByDate) Less(i, j int) bool

func (ByDate) Swap

func (a ByDate) Swap(i, j int)

type ByName

type ByName []RSVP

ByName sorts RSVPs by name.

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type Event

type Event struct {
	ID          int       `json:"id"`
	Title       string    `json:"title"`
	Fragment    string    `json:"fragment"`
	Description string    `json:"description"`
	Location    string    `json:"location"`
	CoverPhoto  string    `json:"coverPhoto"`
	StartTime   time.Time `json:"startTime"`
	EndTime     time.Time `json:"endTime"`
	AllDay      bool      `json:"allDay"`
	OpenSignup  bool      `json:"openSignup"`
	RSVP        []RSVP    `json:"rsvp"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
}

Event holds information about events.

func All

func All() ([]*Event, error)

All returns all the events.

func Load

func Load(id int) (*Event, error)

Load an event by its ID.

func LoadFragment

func LoadFragment(fragment string) (*Event, error)

LoadFragment loads an event by its URL fragment.

func New

func New() *Event

New creates a blank event with sensible defaults.

func (*Event) Delete

func (ev *Event) Delete() error

Delete an event.

func (*Event) InviteContactID

func (ev *Event) InviteContactID(id int) error

InviteContactID enters an invitation for a contact ID.

func (*Event) ParseForm

func (ev *Event) ParseForm(r *http.Request)

ParseForm populates the event from form values.

func (*Event) Save

func (ev *Event) Save() error

Save the event.

func (Event) Uninvite

func (ev Event) Uninvite(id int) error

Uninvite removes an RSVP.

func (*Event) Validate

func (ev *Event) Validate() error

Validate makes sure the required fields are all present.

type RSVP

type RSVP struct {
	// If the user was invited by an admin, they will have a ContactID and
	// not much else. Users who signed up themselves from an OpenSignup event
	// will have the metadata filled in instead.
	ID        int              `json:"id"`
	ContactID int              `json:"contactId"`
	EventID   int              `json:"eventId"`
	Contact   contacts.Contact `json:"-" gorm:"save_associations:false"` // rel table not serialized to JSON
	Status    string           `json:"status"`                           // invited, going, maybe, not going
	Notified  bool             `json:"notified"`
	Name      string           `json:"name,omitempty"`
	Email     string           `json:"email,omitempty"`
	SMS       string           `json:"sms,omitempty"`
	Created   time.Time        `json:"created"`
	Updated   time.Time        `json:"updated"`
}

RSVP tracks invitations and confirmations to events.

func (RSVP) GetEmail

func (r RSVP) GetEmail() string

GetEmail gets the user's email (from the contact or the anonymous email).

func (RSVP) GetName

func (r RSVP) GetName() string

GetName of the user in the RSVP (from the contact or the anonymous name).

func (RSVP) GetSMS

func (r RSVP) GetSMS() string

GetSMS gets the user's SMS number (from the contact or the anonymous sms).

func (RSVP) Save

func (r RSVP) Save() error

Save the RSVP.

Jump to

Keyboard shortcuts

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