Documentation
¶
Index ¶
- Variables
- func CanUserSeeTraining(user User, training Training) error
- func CancelBalanceDelta(tr Training, cancelingUserType UserType) int
- type CantRescheduleBeforeTimeError
- type ForbiddenToSeeTrainingError
- type NotFoundError
- type Repository
- type Training
- func (t *Training) ApproveReschedule(userType UserType) error
- func (t Training) CanBeCanceledForFree() bool
- func (t *Training) Cancel() error
- func (t Training) IsCanceled() bool
- func (t *Training) IsRescheduleProposed() bool
- func (t Training) MovedProposedBy() UserType
- func (t Training) Notes() string
- func (t *Training) ProposeReschedule(newTime time.Time, proposerType UserType)
- func (t Training) ProposedNewTime() time.Time
- func (t *Training) RejectReschedule() error
- func (t *Training) RescheduleTraining(newTime time.Time) error
- func (t Training) Time() time.Time
- func (t Training) UUID() string
- func (t *Training) UpdateNotes(notes string) error
- func (t Training) UserName() string
- func (t Training) UserUUID() string
- type User
- type UserType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Trainer = UserType{"trainer"} Attendee = UserType{"attendee"} )
View Source
var ErrNoRescheduleRequested = errors.New("no training reschedule was requested yet")
View Source
var ErrNoteTooLong = commonerrors.NewIncorrectInputError("Note too long", "note-too-long")
View Source
var ErrTrainingAlreadyCanceled = errors.New("training is already canceled")
Functions ¶
func CanUserSeeTraining ¶
func CancelBalanceDelta ¶
CancelBalanceDelta return trainings balance delta that should be adjusted after training cancellation.
Types ¶
type CantRescheduleBeforeTimeError ¶
func (CantRescheduleBeforeTimeError) Error ¶
func (c CantRescheduleBeforeTimeError) Error() string
type ForbiddenToSeeTrainingError ¶
func (ForbiddenToSeeTrainingError) Error ¶
func (f ForbiddenToSeeTrainingError) Error() string
type NotFoundError ¶
type NotFoundError struct {
TrainingUUID string
}
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Repository ¶
type Repository interface { AddTraining(ctx context.Context, tr *Training) error GetTraining(ctx context.Context, trainingUUID string, user User) (*Training, error) UpdateTraining( ctx context.Context, trainingUUID string, user User, updateFn func(ctx context.Context, tr *Training) (*Training, error), ) error }
type Training ¶
type Training struct {
// contains filtered or unexported fields
}
func NewTraining ¶
func UnmarshalTrainingFromDatabase ¶
func UnmarshalTrainingFromDatabase( uuid string, userUUID string, userName string, trainingTime time.Time, notes string, canceled bool, proposedNewTime time.Time, moveProposedBy UserType, ) (*Training, error)
UnmarshalTrainingFromDatabase unmarshals Training from the database.
It should be used only for unmarshalling from the database! You can't use UnmarshalTrainingFromDatabase as constructor - It may put domain into the invalid state!
func (*Training) ApproveReschedule ¶
func (Training) CanBeCanceledForFree ¶
func (Training) IsCanceled ¶
func (*Training) IsRescheduleProposed ¶
func (Training) MovedProposedBy ¶
func (*Training) ProposeReschedule ¶
func (Training) ProposedNewTime ¶
func (*Training) RejectReschedule ¶
func (*Training) RescheduleTraining ¶
func (*Training) UpdateNotes ¶
type UserType ¶
type UserType struct {
// contains filtered or unexported fields
}
UserType is enum-like type By using struct with hidden field, we ensure immutability instead of declaring string as a UserType and using constants
func NewUserTypeFromString ¶
Click to show internal directories.
Click to hide internal directories.