Skip to content

Commit

Permalink
model and api for issue #13
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyt committed Nov 2, 2016
1 parent 359f872 commit 4ce307e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
16 changes: 16 additions & 0 deletions src/tyt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func installAPI(db *buntdb.DB) {
factory: func() IEntity { return &Team{} },
}.install()

// organizations API
API{
db: db,
resource: "org",
collection: "orgs",
factory: func() IEntity { return &Organization{} },
}.install()

// events API
API{
db: db,
Expand All @@ -91,5 +99,13 @@ func installAPI(db *buntdb.DB) {
factory: func() IEntity { return &Event{} },
}.install()

// events API
API{
db: db,
resource: "spectacle",
collection: "spectacles",
factory: func() IEntity { return &Spectacle{} },
}.install()

// TODO api to change user password
}
30 changes: 25 additions & 5 deletions src/tyt/model.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"github.com/satori/go.uuid"
"time"

"github.com/satori/go.uuid"
)

type IEntity interface {
Expand Down Expand Up @@ -56,13 +57,23 @@ type User struct {
}

type Team struct {
Entity
OrganizationID string `json:"organization_id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Slug string `json:"slug,omitempty"`
Github string `json:"github,omitempty"` // github URL
Telegram string `json:"telegram,omitempty"` // team chat
Members []string `json:"members,omitempty"` // member ids
}

type Organization struct {
Entity
Name string `json:"name"`
Description string `json:"description,omitempty"`
Slug string `json:"slug,omitempty"`
Github string `json:"github,omitempty"` // github URL
Telegram string `json:"telegram,omitempty"` // team chat
Members []string `json:"members,omitempty"` // member ids
Github string `json:"github,omitempty"` // organization github URL
Teams []string `json:"teams,omitempty"` // team ids
}

type Event struct {
Expand All @@ -73,5 +84,14 @@ type Event struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
// allow to track just time spent in hours
Duration int32 `json:"duration"`
Duration int32 `json:"duration"`
SpectacleID string `json:"spectacle_id,omitempty"`
}

type Spectacle struct {
Entity
Type string `json:"type"`
Title string `json:"title"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}

0 comments on commit 4ce307e

Please sign in to comment.