Documentation ¶
Index ¶
Constants ¶
const ErrorCannotAccessRessource = "You can not access this ressource"
ErrorCannotAccessRessource = "You can not access this ressource" with 403 http.StatusForbidden
const ErrorIDDoesNotExist = "id does not exist"
ErrorIDDoesNotExist = "id does not exist" with 404 http.StatusNotFound
const ErrorIDIsMissing = "id is missing"
ErrorIDIsMissing = "id is missing" with 404 http.StatusNotFound
const ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource."
ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource." with 405 http.StatusMethodNotAllowed
const ErrorParentNotFound = "Could not get the parent associated to the object"
ErrorParentNotFound = "Could not get the parent associated to the object" with 500 http.StatusInternalServerError
const ErrorRoleOfLoggedUser = "Could not get role of logged user"
ErrorRoleOfLoggedUser = "Could not get role of logged user" with 500 http.StatusInternalServerError
const ErrorValidateVote = "Error in the process to validate a vote"
ErrorValidateVote = "Error in the process to validate a vote" with 500 http.StatusInternalServerError
const ErrorValidatedVote = "Error the vote have already been validated and can't be updated"
ErrorValidatedVote = "Error the vote have already been validated and can't be updated" with 500 http.StatusInternalServerError
const ErrorVoteExist = "Error the vote have already been captured"
ErrorVoteExist = "Error the vote have already been captured" with 500 http.StatusInternalServerError
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Area ¶
type Area struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` ElectionID uint Name string SeatNumber uint MapID string Sections []Section }
Area represent an area of an election divided in one or several Sections
type Candidate ¶
type Candidate struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` CandidateListID uint FullName string Rank uint CommunityCounseller bool Birthdate string PotentialIncompatibility bool Refused bool Removed bool }
Candidate is a candiate presented on a list
type CandidateList ¶
type CandidateList struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` Name string PartyID uint RoundID uint AreaID uint `gorm:"foreignkey:AreaRefer"` Candidates []Candidate Votes []Vote }
CandidateList is a list presented in an Area on an election
type Capturer ¶
type Capturer struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` UserID int `gorm:"not null;unique"` Name string DeskRounds []DeskRound `gorm:"many2many:capturer_deskrounds;"` }
Capturer is a user who can capture the results on the desks he is affected
type DataHandler ¶
type DataHandler struct {
// contains filtered or unexported fields
}
DataHandler init a gorm DB an presents API handlers
func NewDataHandler ¶
func NewDataHandler() *DataHandler
NewDataHandler init a DataHandler and returns a pointer to it
func (*DataHandler) ProcessAPI ¶
func (d *DataHandler) ProcessAPI(w http.ResponseWriter, r *http.Request)
ProcessAPI redirect API call to DataHandler to each correct API func
type Desk ¶
type Desk struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` SectionID uint Name string WitnessDesk bool Subscribed uint DeskRounds []DeskRound }
Desk represent a Desk office to vote from a section with the number of subscribed. It can be set to be a witness desk
type DeskRound ¶
type DeskRound struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` RoundID uint DeskID uint Capturers []Capturer `gorm:"many2many:capturer_deskrounds;"` Completed bool DateCompletion time.Time Validated bool Votes []Vote }
DeskRound is a duplicate instance of a Desk to save the result for a round
type Election ¶
type Election struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` Name string BallotType string MapAreaFile string MapSectionFile string Areas []Area Rounds []Round }
Election represent an election divided in areas with 1 or several rounds
type Parameter ¶
type Parameter struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` RoundID uint CountBlankAndNull bool ShowOnlyCompleted bool ShowMap bool }
Parameter save the parameter for a round
type Party ¶
type Party struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` Name string Color string CandidateLists []CandidateList }
Party represent a political party or tendance
type Round ¶
type Round struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` ElectionID uint Parameter Parameter Date string Round uint DeskRounds []DeskRound CandidateLists []CandidateList }
Round represent a round for an election
type Section ¶
type Section struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` AreaID uint Name string MapID string Desks []Desk }
Section represent a section of an area divided in 1 or several Desks
type Vote ¶
type Vote struct { ID uint `gorm:"primary_key"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt *time.Time `json:"-"` DeskRoundID uint CandidateListID uint VoiceNumber uint Blank bool NullVote bool }
Vote represent the number of voice between a CandidateList and a Desk (+blank and null)