Skip to content
Snippets Groups Projects
Commit 93941b77 authored by Alexis Poyen's avatar Alexis Poyen
Browse files

Feat : add models for elections

parent 2d18b6c5
No related branches found
No related tags found
1 merge request!1Resolve "Data model"
...@@ -3,6 +3,7 @@ package models ...@@ -3,6 +3,7 @@ package models
import ( import (
"net/http" "net/http"
"strings" "strings"
"time"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
...@@ -30,6 +31,144 @@ const ErrorRoleOfLoggedUser = "Could not get role of logged user" ...@@ -30,6 +31,144 @@ const ErrorRoleOfLoggedUser = "Could not get role of logged user"
// ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource." // ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource."
const ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource." const ErrorNotAuthorizeMethodOnRessource = "You're not authorize to execute this method on this ressource."
type election struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
name string
ballotType string
areas []area
Rounds []Round
}
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
}
type section struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
areaID uint
name string
seatNumber uint
mapID string
desks []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
subscribed uint
witnessDesk bool
}
type party struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
name string
color string
candidateList []candidateList
}
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
}
type parameter struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
roundID round
countBalnkAndNull bool
showOnlyCompleted bool
showMap bool
}
type round struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
ElectionID uint
parameter parameter
name string
date time.Time
tour uint
deskRounds []deskRound
}
type deskRound struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
RoundID uint
completed bool
dateCompletion time.Time
validated bool
Votes []Vote
}
type candidateList struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
PartyID uint
name string
candidates []candidate
Votes []Vote
}
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 time.Time
potentialIncompatibility bool
refused bool
removed bool
}
type vote struct {
deskRoundID uint `gorm:"primary_key"`
candidateListID uint `gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
voiceNumber uint
blank bool
null bool
}
// NewDataHandler init a DataHandler and returns a pointer to it // NewDataHandler init a DataHandler and returns a pointer to it
func NewDataHandler() *DataHandler { func NewDataHandler() *DataHandler {
db, err := gorm.Open("sqlite3", "./data/test.db") db, err := gorm.Open("sqlite3", "./data/test.db")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment