Exemple #1
0
func EventListHandler(r render.Render) {

	search := bson.M{"data.start_time": bson.M{"$gte": time.Now()}}
	sort := "data.start_time"
	var results []Event
	err := db.Find(&Event{}, search).Sort(sort).All(&results)
	if err != nil && err != mgo.ErrNotFound {
		panic(err)
	}

	if err == mgo.ErrNotFound {
		fmt.Println("No such object in db. Redirect")
		//http.Redirect(w, r, "/404/", http.StatusFound)
		return
	}

	type templateData struct {
		Context *conf.Context
		Events  []Event
	}

	data := templateData{conf.DefaultContext(conf.Config), results}

	r.HTML(200, "event_list", data)

}
Exemple #2
0
func NotFoundHandler(r render.Render) {

	type templateData struct {
		Context *conf.Context
	}

	data := templateData{conf.DefaultContext(conf.Config)}

	r.HTML(200, "404", data)
}
Exemple #3
0
func HomeHandler(r render.Render) {

	type templateData struct {
		Context *conf.Context
	}

	data := templateData{conf.DefaultContext(conf.Config)}

	r.HTML(200, "home", data)
}
Exemple #4
0
func EventGrabHandler(r render.Render) {

	type templateData struct {
		Context *conf.Context
	}

	data := templateData{conf.DefaultContext(conf.Config)}

	r.HTML(200, "event_grab", data)

}
Exemple #5
0
func FacebookLoginHandler(r render.Render) {

	// simple static page for user to click on fb connect button

	type templateData struct {
		Context *conf.Context
	}

	data := templateData{conf.DefaultContext(conf.Config)}

	r.HTML(200, "facebook_login", data)

}
Exemple #6
0
func FacebookChannelHandler(w http.ResponseWriter, req *http.Request) {

	var fbchannel = template.Must(template.ParseFiles(
		path.Join(conf.Config.ProjectRoot, "templates/channel.html"),
	))

	type templateData struct {
		Context *conf.Context
	}

	data := templateData{conf.DefaultContext(conf.Config)}

	fbchannel.Execute(w, data)
}
Exemple #7
0
func ShowEventAttendees(params martini.Params, mdb *mgo.Database, r render.Render) {

	fmt.Println("Show event attendees")

	var attendees []Attendee
	fmt.Println(params["eid"])
	mdb.C("attendees").Find(bson.M{"eid": params["eid"]}).All(&attendees)

	type templateData struct {
		Context   *conf.Context
		Attendees []Attendee
	}

	data := templateData{conf.DefaultContext(conf.Config), attendees}

	r.HTML(200, "event_attendees", data)

}
Exemple #8
0
// Add Event from Website (incomplete)
func EventAddHandler(w http.ResponseWriter, req *http.Request) {

	// Public facing page that allows users (required field email and event title) to submit a topic
	// TODO: implement check to ensure user submitted event provides an email

	var eventadd = template.Must(template.ParseFiles(
		path.Join(conf.Config.ProjectRoot, "templates/_base.html"),
		path.Join(conf.Config.ProjectRoot, "templates/event_add.html"),
	))

	type templateData struct {
		Context *conf.Context
	}

	data := templateData{conf.DefaultContext(conf.Config)}

	// if request method is a GET, we will simply render the page
	if req.Method != "POST" {
		eventadd.Execute(w, data)
		return
	}

	// else if it is a POST, let's add our event
	event := NewEvent()
	event.Name = req.FormValue("name")
	event.Description = req.FormValue("description")

	// TODO: validation
	//if event.Name == "" {
	//fmt.Println("No event name submitted")
	//}

	//if event.Description == "" {
	//fmt.Println("No event description submitted")
	//}

	db.Upsert(event)

	http.Redirect(w, req, "/", http.StatusTemporaryRedirect)

}
Exemple #9
0
func EventNextHandler(r render.Render) {

	search := bson.M{"data.start_time": bson.M{"$gte": time.Now()}}
	sort := "data.start_time"
	var results []Event
	err := db.Find(&Event{}, search).Sort(sort).Limit(2).All(&results)
	fmt.Println(results)

	if err != nil && err != mgo.ErrNotFound {
		panic(err)
	}

	type templateData struct {
		Context *conf.Context
		Events  []Event
	}

	data := templateData{conf.DefaultContext(conf.Config), results}

	r.HTML(200, "event_next", data)

}