Documentation
¶
Overview ¶
Package models contains all of our models and utility functions for creating and modifying them
Index ¶
- Constants
- Variables
- type Comment
- type DataType
- type Field
- type FieldScheme
- type Hook
- type Notification
- type Project
- type Role
- type RolePermission
- type Sanitizer
- type Session
- type Settings
- type Status
- type StatusType
- type Ticket
- type Transition
- type User
- type UserRole
- type Users
- type Workflow
- type WorkflowMapping
Constants ¶
const ( FloatField DataType = "FLOAT" StringField = "STRING" IntField = "INT" DateField = "DATE" OptionField = "OPTION" )
These are the available data types for fields on Tickets.
const ( StatusTodo StatusType = "TODO" StatusInProgress = "IN_PROGRESS" StatusDone = "Done" // StatusNull is a special type used for transitions that allow from any or // for create transitions StatusNull = "NULL" )
Available status types
Variables ¶
var DataTypes = []DataType{ FloatField, StringField, IntField, DateField, OptionField, }
DataTypes holds the available data types
var ErrInvalidDataType = errors.New("Invalid data type for field")
ErrInvalidDataType indicates that the field was created with an incorrect data type
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct {
ID bson.ObjectId `json:"id"`
UpdatedDate time.Time `json:"updatedDate"`
CreatedDate time.Time `json:"createdDate"`
Body string `json:"body" required:"true"`
Author string `json:"author" required:"true"`
}
Comment is a comment on an issue / ticket.
type DataType ¶
type DataType string
DataType is a string which indicates the type of data in a given field.
type Field ¶
type Field struct {
Name string `json:"name"`
DataType DataType `json:"dataType"`
// Options is only relevant for Fields of DataType OPTION
Options []string `json:"options,omitempty" bson:"options,omitempty"`
// Value holds the value of the given field
Value interface{} `json:"value,omitempty" bson:"value,omitempty"`
}
Field is a ticket field
func (Field) IsValidDataType ¶
IsValidDataType is used to verify that the field has a data type we can support
type FieldScheme ¶
type FieldScheme struct {
ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
Name string `json:"name" required:"true"`
// Map ticket type to fields
Fields map[string][]Field `json:"fields"`
}
FieldScheme assigns fields to a ticke type.
func (FieldScheme) ValidateTicket ¶
func (fs FieldScheme) ValidateTicket(t Ticket) error
ValidateTicket verifies that all fields on t are valid
type Hook ¶
type Hook struct {
Endpoint string `json:"endpoint"`
Method string `json:"method"`
Body string `json:"body"`
}
Hook contains information about what webhooks to fire when a given transition is run.
type Notification ¶
type Notification struct {
ID bson.ObjectId `bson:"_id" json:"id"`
Project string `json:"project"`
ActioningUser string `json:"actioningUser"`
ActionedTicket string `json:"actionedTicket"`
Type string `json:"eventType"`
Body string `json:"body"`
Read bool `json:"read"`
Watcher string `json:"watcher"`
CreatedDate time.Time `json:"createdDate"`
}
Notification is any kind of activity on a project for which a user might want an auditble history of
type Project ¶
type Project struct {
Key string `json:"key" bson:"_id" required:"true"`
Name string `json:"name" required:"true"`
CreatedDate time.Time `json:"createdDate"`
Lead string `json:"lead"`
Homepage string `json:"homepage,omitempty"`
Repo string `json:"repo,omitempty"`
TicketTypes []string `json:"ticketTypes"`
Public bool `json:"public"`
Permissions []RolePermission `json:"permissions"`
FieldScheme bson.ObjectId `json:"fieldScheme"`
// Map ticket types to workflow ID's
WorkflowScheme []WorkflowMapping `json:"workflowScheme"`
Icon *mgo.GridFile `json:"-"`
}
Project is the model used to represent a project in the database.
func HasPermission ¶
func HasPermission(permName permission.Permission, user User, projects ...Project) []Project
HasPermission will return a slice of projects for which the given user has the permission indicated out of the projects given.
func (Project) GetPermsForRoles ¶
func (p Project) GetPermsForRoles(roles ...Role) permission.Permissions
GetPermsForRoles will take the given roles and return a slice of Permissions that those roles have NOTE: It does not remove duplicates so some permissions may exist more than once
func (Project) GetWorkflow ¶
GetWorkflow will return the ID of the workflow to use for tickets of the given type for this project.
func (Project) HasTicketType ¶
HasTicketType is used to validate whether the given ticket type exists for this project
type Role ¶
type Role string
Role is an alias type to make it's use more clear inside of other models.
type RolePermission ¶
type RolePermission struct {
Role Role `json:"role"`
Permission permission.Permission `json:"permission"`
}
RolePermission maps a role to a permission on a project
type Sanitizer ¶
type Sanitizer interface {
Sanitize() interface{}
}
Sanitizer is implemented by any model which needs to be sanitized before being JSON serialized
type Settings ¶
type Settings struct {
DefaultProject string `json:"defaultProject,omitempty"`
DefaultView string `json:"defaultView,omitempty"`
}
Settings represents an individual users preferences
type Status ¶
type Status struct {
Name string `bson:"name" json:"name"`
Type StatusType `bson:"type" json:"type"`
}
Status is a ticket and workflow status
type StatusType ¶
type StatusType string
StatusType represents the statuses type based on the basic three types: TODO, In Progress, or Done
type Ticket ¶
type Ticket struct {
CreatedDate time.Time `json:"createdDate"`
UpdatedDate time.Time `json:"updatedDate"`
Key string `bson:"_id" json:"key"`
Summary string `json:"summary" required:"true"`
Description string `json:"description" required:"true"`
Status Status `json:"status"`
Reporter string `json:"reporter" required:"true"`
Assignee string `json:"assignee"`
Type string `json:"type" required:"true"`
Labels []string `json:"labels"`
Watchers []string `json:"watchers"`
Fields []Field `json:"fields"`
Comments []Comment `json:"comments,omitempty"`
Workflow bson.ObjectId `json:"workflow"`
Project string `json:"project" required:"true"`
}
Ticket represents a ticket
func (Ticket) Transition ¶
Transition searches through the available transitions for the ticket returning a boolean indicating success or failure and the transition
type Transition ¶
type Transition struct {
Name string `json:"name"`
FromStatus Status `json:"fromStatus"`
ToStatus Status `json:"toStatus"`
Hooks []Hook `json:"hooks"`
}
Transition contains information about what hooks to perform when performing a transition
func (Transition) String ¶
func (t Transition) String() string
type User ¶
type User struct {
Username string `json:"username" bson:"_id" required:"true"`
Password string `json:"password,omitempty" required:"true"`
Email string `json:"email" required:"true"`
FullName string `json:"fullName" required:"true"`
ProfilePic string `json:"profilePicture" `
IsAdmin bool `json:"isAdmin,omitempty"`
IsActive bool `json:"isActive,omitempty"`
Settings Settings `json:"settings,omitempty"`
Roles []UserRole `json:"roles"`
}
User represents a user of our application
func (User) CheckPw ¶
CheckPw will verify if the given password matches for this user. Logs any errors it encounters
func (User) ProjectsMemberOf ¶
ProjectsMemberOf returns an array of project keys which this user has a role in.
func (User) RolesForProject ¶
RolesForProject will return an array of the roles a this user has for the given project.
type Workflow ¶
type Workflow struct {
ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
Name string `json:"name" required:"true"`
Transitions []Transition `json:"transitions" required:"true"`
}
Workflow is the container for issues and keeps track of available transitions
func (Workflow) CreateTransition ¶
func (w Workflow) CreateTransition() Transition
CreateTransition will return the transition to perform on a ticket during creation
type WorkflowMapping ¶
type WorkflowMapping struct {
Workflow bson.ObjectId `json:"workflow"`
TicketType string `json:"ticket_type"`
}
WorkflowMapping maps a ticket type to a workflow
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package permission is used to store the various permission in praelatus, it acts as a pseudo-enumeration
|
Package permission is used to store the various permission in praelatus, it acts as a pseudo-enumeration |