model

package
v0.0.0-...-3a56714 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CASTELLTYPESVIEW            = "castell_types_view"
	CASTELLTYPESTABLE           = "castell_types"
	CASTELLPOSITIONSTABLE       = "castell_positions"
	CASTELLMODELSTABLE          = "castell_models"
	CASTELLMODELSVIEW           = "castell_models_view"
	CASTELLMEMBERPOSITIONSTABLE = "castell_members_positions"
	CASTELLMODELSINEVENTSTABLE  = "castell_models_in_events"
	CASTELLMODELSINEVENTSVIEW   = "castell_models_with_events_view"
)
View Source
const (
	MEMBERSTABLE            = "members"
	MEMBERSCREDENTIALSTABLE = "members_credentials"
	MEMBERSDEPENDANTSTABLE  = "members_dependent"

	MEMBERSTYPEADMIN   = "admin"
	MEMBERSTYPEREGULAR = "member"
	MEMBERSTYPECANALLA = "canalla"
	MEMBERSTYPEGUEST   = "guest"

	MEMBERSSTATUSCREATED   = "created"
	MEMBERSSTATUSACTIVATED = "active"
	MEMBERSSTATUSPAUSED    = "paused"
	MEMBERSSTATUSDELETED   = "deleted"
	MEMBERSSTATUSPURGED    = "purged"

	MEMBERSEMAILNOTFOUNDMESSAGE = "no member found with this email"
)
View Source
const EVENTS_TABLE = "events"
View Source
const NotificationDeliveryFailure = 2
View Source
const NotificationDeliveryInProgress = 99
View Source
const NotificationDeliveryPartialFailure = 3
View Source
const NotificationDeliverySuccess = 1
View Source
const NotificationNotDelivered = 0
View Source
const NotificationTooLate = 98
View Source
const PARTICIPATION_TABLE = "participation"
View Source
const RECURRING_EVENTS_TABLE = "recurring_events"
View Source
const TypeEventCreated = "eventCreated"
View Source
const TypeEventDeleted = "eventDeleted"
View Source
const TypeEventModified = "eventModified"
View Source
const TypeForgotPassword = "forgotPassword"
View Source
const TypeMemberRegistration = "memberRegistration"
View Source
const TypeSummaryEvent = "summaryEvent"
View Source
const TypeUpcomingEvent = "upcomingEvent"

Variables

View Source
var ValidEventTypes = []string{
	"presentation",
	"practice",
	"social",
}
View Source
var ValidLanguageList = []string{
	"fr",
	"en",
	"cat",
}
View Source
var ValidRoleList = []string{
	"baix",
	"contrafort",
	"primera mà",
	"segona mà",
	"lateral",
	"vent",
	"agulla",
	"crossa",
	"segon",
	"terç",
	"quart",
	"dos",
	"acotxador",
	"enxaneta",
	"pinya",
}

Functions

func InitializeDB

func InitializeDB(dbname string)

func ValidNumberOrEmpty

func ValidNumberOrEmpty(field string) error

func ValidateLanguage

func ValidateLanguage(language string) error

func ValidateRoles

func ValidateRoles(roles []string) error

func ValidateType

func ValidateType(memberType string) error

Types

type CastellModel

type CastellModel struct {
	UUID            string                   `json:"uuid"`
	Name            string                   `json:"name"`
	Type            string                   `json:"type"` // Will be the name of the castell type, ie: 3d6
	PositionMembers []CastellPositionMembers `json:"position_members,omitempty"`
	Event           CastellModelEvent        `json:"event,omitempty"`
}

func (*CastellModel) AttachToEvent

func (c *CastellModel) AttachToEvent(ctx context.Context, e *Event) error

func (*CastellModel) Create

func (c *CastellModel) Create(ctx context.Context) error

func (*CastellModel) Delete

func (c *CastellModel) Delete(ctx context.Context) error

func (*CastellModel) DettachFromEvent

func (c *CastellModel) DettachFromEvent(ctx context.Context, e *Event) error

func (*CastellModel) Edit

func (c *CastellModel) Edit(ctx context.Context) error

func (*CastellModel) Get

func (c *CastellModel) Get(ctx context.Context) error

func (*CastellModel) GetAll

func (c *CastellModel) GetAll(ctx context.Context) ([]CastellModel, error)

func (*CastellModel) GetAllFromEvent

func (c *CastellModel) GetAllFromEvent(ctx context.Context, event Event) ([]CastellModel, error)

type CastellModelEvent

type CastellModelEvent struct {
	Name      string `json:"name"`
	UUID      string `json:"uuid"`
	StartDate uint   `json:"start"`
}

type CastellPosition

type CastellPosition struct {
	Name   string `json:"name"`
	Column int    `json:"column"`
	Cordon int    `json:"cordon"`
	Part   string `json:"part"`
}

type CastellPositionMembers

type CastellPositionMembers struct {
	MemberUUID string          `json:"member_uuid"`
	Position   CastellPosition `json:"position"`
}

type CastellType

type CastellType struct {
	Name      string            `json:"name"`
	Positions []CastellPosition `json:"positions"`
}

func (*CastellType) Get

func (c *CastellType) Get(ctx context.Context) error

func (*CastellType) GetTypeList

func (c *CastellType) GetTypeList(ctx context.Context) ([]string, error)

type Credentials

type Credentials struct {
	UUID           string `json:"-"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	PasswordHashed []byte `json:"-"`
}

func (*Credentials) GetCredentials

func (c *Credentials) GetCredentials(ctx context.Context) error

func (*Credentials) GetCredentialsByUUID

func (c *Credentials) GetCredentialsByUUID(ctx context.Context) error

func (*Credentials) ResetCredentials

func (c *Credentials) ResetCredentials(ctx context.Context, username string, password []byte) error

type Event

type Event struct {
	UUID           string    `json:"uuid"`
	Name           string    `json:"name"`
	Description    string    `json:"description"`
	StartDate      uint      `json:"startDate"`
	EndDate        uint      `json:"endDate"`
	Recurring      Recurring `json:"recurring"`
	Type           string    `json:"type"`
	Participation  string    `json:"participation"`
	Attendance     uint      `json:"attendance"`
	Location       LatLng    `json:"location"`
	LocationName   string    `json:"locationName"`
	RecurringEvent string
}

func (*Event) CreateEvent

func (e *Event) CreateEvent(ctx context.Context) error

func (*Event) DeleteEvent

func (e *Event) DeleteEvent(ctx context.Context) error

func (*Event) Get

func (e *Event) Get(ctx context.Context) error

func (*Event) GetAll

func (e *Event) GetAll(ctx context.Context, page, limit int, pastEvents bool) ([]Event, error)

func (*Event) GetAttendance

func (e *Event) GetAttendance(ctx context.Context) error

func (*Event) GetUpcomingEventsWithoutNotification

func (e *Event) GetUpcomingEventsWithoutNotification(ctx context.Context, eventType string) ([]Event, error)

func (*Event) UpdateEvent

func (e *Event) UpdateEvent(ctx context.Context) error

type LatLng

type LatLng struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

type Member

type Member struct {
	UUID          string   `json:"uuid"`
	FirstName     string   `json:"firstName"` // Encrypted
	LastName      string   `json:"lastName"`  // Encrypted
	Height        string   `json:"height"`    // Encrypted
	Weight        string   `json:"weight"`    // Encrypted
	Roles         []string `json:"roles"`     // Encrypted
	Extra         string   `json:"extra"`     // Encrypted
	Email         string   `json:"email"`     // Encrypted
	Contact       string   `json:"contact"`   // Encrypted
	Type          string   `json:"type"`
	Status        string   `json:"status"`
	Subscribed    int      `json:"subscribed"`
	Language      string   `json:"language"`
	Participation string   `json:"participation"`
	Presence      string   `json:"presence"`
}

func (*Member) AddDependent

func (m *Member) AddDependent(ctx context.Context, dependent *Member) error

func (*Member) CreateMember

func (m *Member) CreateMember(ctx context.Context) error

func (*Member) DeleteMember

func (m *Member) DeleteMember(ctx context.Context) error

func (*Member) EditMember

func (m *Member) EditMember(ctx context.Context) error

func (*Member) Get

func (m *Member) Get(ctx context.Context) error

func (*Member) GetAll

func (m *Member) GetAll(ctx context.Context, memberStatusList, memberTypeList []string) ([]Member, error)

func (*Member) GetByEmail

func (m *Member) GetByEmail(ctx context.Context) error

func (*Member) GetDependents

func (m *Member) GetDependents(ctx context.Context) ([]Member, error)

func (*Member) GetMemberLastParticipation

func (m *Member) GetMemberLastParticipation(ctx context.Context) (Event, error)

func (*Member) RemoveDependent

func (m *Member) RemoveDependent(ctx context.Context, dependent *Member) error

func (*Member) SetStatus

func (m *Member) SetStatus(ctx context.Context, status string) error

type Notification

type Notification struct {
	ID               int
	NotificationType string
	ObjectUUID       string // TODO: remove this field
	SendDate         int
	Delivered        int
	Payload          []byte
}

func (*Notification) CreateNotification

func (n *Notification) CreateNotification(ctx context.Context) error

func (*Notification) GetNotificationsReady

func (n *Notification) GetNotificationsReady(ctx context.Context) ([]Notification, error)

func (*Notification) UpdateNotificationStatus

func (n *Notification) UpdateNotificationStatus(ctx context.Context) error

type Participation

type Participation struct {
	EventUUID  string `json:"eventUuid"`
	MemberUUID string `json:"memberUuid"`
	Answer     string `json:"answer"`
	Presence   string `json:"presence"`
}

func (*Participation) GetParticipation

func (p *Participation) GetParticipation(ctx context.Context) error

func (*Participation) Participate

func (p *Participation) Participate(ctx context.Context) error

A member will say if he or she participates BEFORE the event: We always insert in the table

func (*Participation) Present

func (p *Participation) Present(ctx context.Context) error

A member might be present even if he is not registered for the event

type Recurring

type Recurring struct {
	Interval string `json:"interval"`
	Until    uint   `json:"until"`
}

type RecurringEvent

type RecurringEvent struct {
	UUID        string
	Name        string
	Description string
	Interval    string
}

func (*RecurringEvent) CreateRecurringEvent

func (r *RecurringEvent) CreateRecurringEvent(ctx context.Context) error

func (*RecurringEvent) Get

func (r *RecurringEvent) Get(ctx context.Context) error

Jump to

Keyboard shortcuts

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