project

package
v0.0.0-...-e61ee7f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const GhostProjectID = -1

Ghost Project is a project which has been deleted

Variables

View Source
var ColumnColorPattern = regexp.MustCompile("^#[0-9a-fA-F]{6}$")

ColumnColorPattern is a regexp witch can validate ColumnColor

Functions

func ChangeProjectStatus

func ChangeProjectStatus(ctx context.Context, p *Project, isClosed bool) error

ChangeProjectStatus toggle a project between opened and closed

func ChangeProjectStatusByRepoIDAndID

func ChangeProjectStatusByRepoIDAndID(ctx context.Context, repoID, projectID int64, isClosed bool) error

ChangeProjectStatusByRepoIDAndID toggles a project between opened and closed

func DeleteAllProjectIssueByIssueIDsAndProjectIDs

func DeleteAllProjectIssueByIssueIDsAndProjectIDs(ctx context.Context, issueIDs, projectIDs []int64) error

DeleteAllProjectIssueByIssueIDsAndProjectIDs delete all project's issues by issue's and project's ids

func DeleteColumnByID

func DeleteColumnByID(ctx context.Context, columnID int64) error

DeleteColumnByID removes all issues references to the project column.

func DeleteProjectByID

func DeleteProjectByID(ctx context.Context, id int64) error

DeleteProjectByID deletes a project from a repository. if it's not in a database transaction, it will start a new database transaction

func DeleteProjectByRepoID

func DeleteProjectByRepoID(ctx context.Context, repoID int64) error

func GetAllProjectsIDsByOwnerIDAndType

func GetAllProjectsIDsByOwnerIDAndType(ctx context.Context, ownerID int64, projectType Type) ([]int64, error)

GetAllProjectsIDsByOwnerID returns the all projects ids it owns

func GetSearchOrderByBySortType

func GetSearchOrderByBySortType(sortType string) db.SearchOrderBy

func IsCardTypeValid

func IsCardTypeValid(p CardType) bool

IsCardTypeValid checks if the project column card type is valid

func IsErrProjectColumnNotExist

func IsErrProjectColumnNotExist(err error) bool

IsErrProjectColumnNotExist checks if an error is a ErrProjectColumnNotExist

func IsErrProjectNotExist

func IsErrProjectNotExist(err error) bool

IsErrProjectNotExist checks if an error is a ErrProjectNotExist

func IsTemplateTypeValid

func IsTemplateTypeValid(p TemplateType) bool

IsTemplateTypeValid checks if the project template type is valid

func IsTypeValid

func IsTypeValid(p Type) bool

IsTypeValid checks if a project type is valid

func MoveColumnsOnProject

func MoveColumnsOnProject(ctx context.Context, project *Project, sortedColumnIDs map[int64]int64) error

MoveColumnsOnProject sorts columns in a project

func NewColumn

func NewColumn(ctx context.Context, column *Column) error

NewColumn adds a new project column to a given project

func NewProject

func NewProject(ctx context.Context, p *Project) error

NewProject creates a new Project The title will be cut off at 255 characters if it's longer than 255 characters.

func SetDefaultColumn

func SetDefaultColumn(ctx context.Context, projectID, columnID int64) error

SetDefaultColumn represents a column for issues not assigned to one

func UpdateColumn

func UpdateColumn(ctx context.Context, column *Column) error

UpdateColumn updates a project column

func UpdateColumnSorting

func UpdateColumnSorting(ctx context.Context, cl ColumnList) error

UpdateColumnSorting update project column sorting

func UpdateProject

func UpdateProject(ctx context.Context, p *Project) error

UpdateProject updates project properties

Types

type CardConfig

type CardConfig struct {
	CardType    CardType
	Translation string
}

CardConfig is used to identify the type of column card that is being used

func GetCardConfig

func GetCardConfig() []CardConfig

GetCardConfig retrieves the types of configurations project column cards could have

type CardType

type CardType uint8

CardType is used to represent a project column card type

const (
	// CardTypeTextOnly is a project column card type that is text only
	CardTypeTextOnly CardType = iota

	// CardTypeImagesAndText is a project column card type that has images and text
	CardTypeImagesAndText
)

type Column

type Column struct {
	ID      int64 `xorm:"pk autoincr"`
	Title   string
	Default bool   `xorm:"NOT NULL DEFAULT false"` // issues not assigned to a specific column will be assigned to this column
	Sorting int8   `xorm:"NOT NULL DEFAULT 0"`
	Color   string `xorm:"VARCHAR(7)"`

	ProjectID int64 `xorm:"INDEX NOT NULL"`
	CreatorID int64 `xorm:"NOT NULL"`

	CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

Column is used to represent column on a project

func GetColumn

func GetColumn(ctx context.Context, columnID int64) (*Column, error)

GetColumn fetches the current column of a project

func (*Column) GetIssues

func (c *Column) GetIssues(ctx context.Context) ([]*ProjectIssue, error)

func (*Column) NumIssues

func (c *Column) NumIssues(ctx context.Context) int

NumIssues return counter of all issues assigned to the column

func (Column) TableName

func (Column) TableName() string

TableName return the real table name

type ColumnList

type ColumnList []*Column

ColumnList is a list of all project columns in a repository

func GetColumnsByIDs

func GetColumnsByIDs(ctx context.Context, projectID int64, columnsIDs []int64) (ColumnList, error)

type ErrProjectColumnNotExist

type ErrProjectColumnNotExist struct {
	ColumnID int64
}

ErrProjectColumnNotExist represents a "ErrProjectColumnNotExist" kind of error.

func (ErrProjectColumnNotExist) Error

func (err ErrProjectColumnNotExist) Error() string

func (ErrProjectColumnNotExist) Unwrap

func (err ErrProjectColumnNotExist) Unwrap() error

type ErrProjectNotExist

type ErrProjectNotExist struct {
	ID     int64
	RepoID int64
}

ErrProjectNotExist represents a "ProjectNotExist" kind of error.

func (ErrProjectNotExist) Error

func (err ErrProjectNotExist) Error() string

func (ErrProjectNotExist) Unwrap

func (err ErrProjectNotExist) Unwrap() error

type Project

type Project struct {
	ID           int64                  `xorm:"pk autoincr"`
	Title        string                 `xorm:"INDEX NOT NULL"`
	Description  string                 `xorm:"TEXT"`
	OwnerID      int64                  `xorm:"INDEX"`
	Owner        *user_model.User       `xorm:"-"`
	RepoID       int64                  `xorm:"INDEX"`
	Repo         *repo_model.Repository `xorm:"-"`
	CreatorID    int64                  `xorm:"NOT NULL"`
	IsClosed     bool                   `xorm:"INDEX"`
	TemplateType TemplateType           `xorm:"'board_type'"` // TODO: rename the column to template_type
	CardType     CardType
	Type         Type

	RenderedContent template.HTML `xorm:"-"`

	CreatedUnix    timeutil.TimeStamp `xorm:"INDEX created"`
	UpdatedUnix    timeutil.TimeStamp `xorm:"INDEX updated"`
	ClosedDateUnix timeutil.TimeStamp
}

Project represents a project

func GetProjectByID

func GetProjectByID(ctx context.Context, id int64) (*Project, error)

GetProjectByID returns the projects in a repository

func GetProjectForRepoByID

func GetProjectForRepoByID(ctx context.Context, repoID, id int64) (*Project, error)

GetProjectForRepoByID returns the projects in a repository

func (*Project) CanBeAccessedByOwnerRepo

func (p *Project) CanBeAccessedByOwnerRepo(ownerID int64, repo *repo_model.Repository) bool

func (*Project) GetColumns

func (p *Project) GetColumns(ctx context.Context) (ColumnList, error)

GetColumns fetches all columns related to a project

func (*Project) GetDefaultColumn

func (p *Project) GetDefaultColumn(ctx context.Context) (*Column, error)

GetDefaultColumn return default column and ensure only one exists

func (*Project) IconName

func (p *Project) IconName() string

func (*Project) IsGhost

func (p *Project) IsGhost() bool

func (*Project) IsOrganizationProject

func (p *Project) IsOrganizationProject() bool

func (*Project) IsRepositoryProject

func (p *Project) IsRepositoryProject() bool
func (p *Project) Link(ctx context.Context) string

Link returns the project's relative URL.

func (*Project) LoadOwner

func (p *Project) LoadOwner(ctx context.Context) (err error)

func (*Project) LoadRepo

func (p *Project) LoadRepo(ctx context.Context) (err error)

func (*Project) NumClosedIssues

func (p *Project) NumClosedIssues(ctx context.Context) int

NumClosedIssues return counter of closed issues assigned to a project

func (*Project) NumIssues

func (p *Project) NumIssues(ctx context.Context) int

NumIssues return counter of all issues assigned to a project

func (*Project) NumOpenIssues

func (p *Project) NumOpenIssues(ctx context.Context) int

NumOpenIssues return counter of open issues assigned to a project

type ProjectIssue

type ProjectIssue struct {
	ID        int64 `xorm:"pk autoincr"`
	IssueID   int64 `xorm:"INDEX"`
	ProjectID int64 `xorm:"INDEX"`

	// ProjectColumnID should not be zero since 1.22. If it's zero, the issue will not be displayed on UI and it might result in errors.
	ProjectColumnID int64 `xorm:"'project_board_id' INDEX"`

	// the sorting order on the column
	Sorting int64 `xorm:"NOT NULL DEFAULT 0"`
}

ProjectIssue saves relation from issue to a project

type SearchOptions

type SearchOptions struct {
	db.ListOptions
	OwnerID  int64
	RepoID   int64
	IsClosed optional.Option[bool]
	OrderBy  db.SearchOrderBy
	Type     Type
	Title    string
}

SearchOptions are options for GetProjects

func (SearchOptions) ToConds

func (opts SearchOptions) ToConds() builder.Cond

func (SearchOptions) ToOrders

func (opts SearchOptions) ToOrders() string

type TemplateConfig

type TemplateConfig struct {
	TemplateType TemplateType
	Translation  string
}

TemplateConfig is used to identify the template type of project that is being created

func GetTemplateConfigs

func GetTemplateConfigs() []TemplateConfig

GetTemplateConfigs retrieves the template configs of configurations project columns could have

type TemplateType

type TemplateType uint8

TemplateType is used to represent a project template type

const (
	// TemplateTypeNone is a project template type that has no predefined columns
	TemplateTypeNone TemplateType = iota

	// TemplateTypeBasicKanban is a project template type that has basic predefined columns
	TemplateTypeBasicKanban

	// TemplateTypeBugTriage is a project template type that has predefined columns suited to hunting down bugs
	TemplateTypeBugTriage
)

type Type

type Type uint8

Type is used to identify the type of project in question and ownership

const (
	// TypeIndividual is a type of project column that is owned by an individual
	TypeIndividual Type = iota + 1

	// TypeRepository is a project that is tied to a repository
	TypeRepository

	// TypeOrganization is a project that is tied to an organisation
	TypeOrganization
)

Jump to

Keyboard shortcuts

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