Skip to content
Snippets Groups Projects
Commit ca255ab7 authored by Mikhail Babynichev's avatar Mikhail Babynichev :blush:
Browse files

fix bug

parent 548b15c4
Branches master
No related tags found
No related merge requests found
stats.db
\ No newline at end of file
football_cms
stats.db
package handlers
func handler_add(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
"strings"
dbstr "../structs"
)
func Handler_add(ctx *macaron.Context) {
var match dbstr.Match
db.First(&match, "Active = ?", 1)
if match.Active != 0 {
......
package handlers
func handler_edit(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
dbstr "../structs"
)
func Handler_edit(ctx *macaron.Context) {
var match dbstr.Match
db.First(&match, "Active = ?", 1)
if match.Active != 0 {
......
package handlers
func handler_edit_main(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
"strconv"
"strings"
dbstr "../structs"
)
func Handler_edit_main(ctx *macaron.Context) {
var match dbstr.Match
db.First(&match, "Active = ?", 1)
if match.Active != 0 {
......
package handlers
func handler_end(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
dbstr "../structs"
)
func Handler_end(ctx *macaron.Context) {
var match dbstr.Match
db.First(&match, "Active = ?", 1)
if match.Active != 0 {
......
package handlers
func handler_error() string {
func Handler_error() string {
return "Произошла какая-то ошибка!"
}
\ No newline at end of file
package handlers
func handler_events_get(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
dbstr "../structs"
)
func Handler_events_get(ctx *macaron.Context) {
var match dbstr.Match
db.First(&match, "Active = ?", 1)
if match.Active != 0 {
events := []Event {}
events := []dbstr.Event {}
db.Find(&events, "Match_id = ?", match.ID)
ctx.Data["Events"] = events
ctx.Data["Matchinfo"] = match
......
package handlers
func handler_index(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
"encoding/json"
dbstr "../structs"
)
func Handler_index(ctx *macaron.Context) {
var match dbstr.Match
var events_team1 dbstr.Match_events
var events_team2 dbstr.Match_events
......
package handlers
import (
"log"
"encoding/json"
"strings"
"gopkg.in/macaron.v1"
"strconv"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
dbstr "../structs"
)
\ No newline at end of file
)
var db, err_db = gorm.Open("sqlite3", "stats.db")
\ No newline at end of file
package handlers
func handler_events_post(ctx *macaron.Context) {
import (
"gopkg.in/macaron.v1"
"strconv"
dbstr "../structs"
)
func Handler_events_post(ctx *macaron.Context) {
var match dbstr.Match
db.First(&match, "Active = ?", 1)
if match.Active != 0 {
......
......@@ -2,10 +2,7 @@ package main
import (
"log"
"encoding/json"
"strings"
"gopkg.in/macaron.v1"
"strconv"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
......@@ -32,15 +29,15 @@ func main() {
db.AutoMigrate(&dbstr.Match{})
db.AutoMigrate(&dbstr.Event{})
m.Get("/", handler.handler_index) // / (GET) - основная страница, шаблон "active.tmpl"
m.Get("/add", handler.handler_add) // /add(GET) - страница для создания матча, шаблон "add.tmpl"
m.Get("/error", handler.handler_error) // /error(GET) - страница для ошибок, *разрабатывается*
m.Get("/end", handler.handler_end) // /end(GET) - мгновенно окончить матч, шаблон отсутствует
m.Get("/medit", handler.handler_edit_main) // /medit(GET) - редактор матча, шаблон "medit.tmpl"
m.Get("/events", handler.handler_events_get) // /events(GET) - редактор событий, шаблон "events.tmpl"
m.Get("/", handler.Handler_index) // / (GET) - основная страница, шаблон "active.tmpl"
m.Get("/add", handler.Handler_add) // /add(GET) - страница для создания матча, шаблон "add.tmpl"
m.Get("/error", handler.Handler_error) // /error(GET) - страница для ошибок, *разрабатывается*
m.Get("/end", handler.Handler_end) // /end(GET) - мгновенно окончить матч, шаблон отсутствует
m.Get("/medit", handler.Handler_edit_main) // /medit(GET) - редактор матча, шаблон "medit.tmpl"
m.Get("/events", handler.Handler_events_get) // /events(GET) - редактор событий, шаблон "events.tmpl"
m.Post("/edit", handler.handler_edit) // /edit(POST) - обновляет события в /
m.Post("/events", handler.handler_events_post) // /events(POST) - добавляет события в /events(GET)
m.Post("/edit", handler.Handler_edit) // /edit(POST) - обновляет события в /
m.Post("/events", handler.Handler_events_post) // /events(POST) - добавляет события в /events(GET)
m.Run("0.0.0.0", 8080)
log.Print("Server started at *:8080")
......
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