예제 #1
0
// Load and parse the hotspots
func Get(c appengine.Context, selectedCity city.City) (hotspots []Hotspot) {
	headerRow := 1
	hotspotsData := spreadsheet.Get(c, selectedCity.SpreadsheetId, selectedCity.SheetId, headerRow)

	for _, hotspotData := range hotspotsData {
		if hotspotData["Visible"] != "y" {
			continue
		}

		var translations []translation.Translation
		translations = append(translations, translation.Translation{"english", hotspotData["Description"]})

		for key, value := range hotspotData {
			_, exists := nonTranslationKeys[key]
			if exists || key == "" {
				continue
			}

			translations = append(translations, translation.Translation{strings.ToLower(key), value})
		}

		hotspots = append(hotspots, Hotspot{
			Category:     mapEmoji(hotspotData["Category"]),
			Name:         hotspotData["Name"],
			Address:      hotspotData["Address"],
			Position:     position.Create(c, hotspotData["Latitude"], hotspotData["Longitude"]),
			Contact:      hotspotData["Contact"],
			OpeningHours: hotspotData["OpeningHours"],
			Translations: translations,
		})
	}

	return
}
예제 #2
0
// Load and parse the categories
func Load(c appengine.Context) (categories []Category) {
	sheetId := "0"
	headerRow := 0
	categoriesData := spreadsheet.Get(c, constants.CategoriesSpreadsheetId, sheetId, headerRow)

	categories = append(categories, allCategories)

	for rowId, categoryData := range categoriesData {
		if rowId == 0 {
			continue
		}

		if categoryData["visible"] != "y" {
			continue
		}

		var translations []translation.Translation

		for key, value := range categoryData {
			if key == "visible" || key == "key" {
				continue
			}

			translations = append(translations, translation.Translation{strings.ToLower(key), value})
		}

		categories = append(categories, Category{
			Key:          categoryData["key"],
			Checked:      false,
			Translations: translations,
		})
	}

	return
}
예제 #3
0
// Get all the pois for that location
func (location Location) GetPois(c appengine.Context) (allPois []poi.Poi) {
	headerRow := 1
	poisData := spreadsheet.Get(c, location.SpreadsheetId, location.SheetId, headerRow)

	for _, poiData := range poisData {
		newPoi, success := poi.Create(c, poiData)

		if success {
			allPois = append(allPois, newPoi)
		}
	}

	return
}
예제 #4
0
// Parse the city data
func load(c appengine.Context) (cities []City) {
	sheetId := "0"
	headerRow := 0
	citiesData := spreadsheet.Get(c, constants.CitySpreadsheetId, sheetId, headerRow)

	for _, cityData := range citiesData {
		if cityData["visible"] != "y" {
			continue
		}

		city := City{
			ID:            cityData["ID"],
			Name:          cityData["City"],
			Position:      position.Create(c, cityData["lat"], cityData["lng"]),
			SpreadsheetId: cityData["Spreadsheet ID"],
			SheetId:       cityData["Sheet ID"],
		}

		cities = append(cities, city)
	}

	return
}
예제 #5
0
// Parse the location data
func All(c appengine.Context) (locations []Location) {
	sheetId := "0"
	headerRow := 0
	locationsData := spreadsheet.Get(c, constants.LocationSpreadsheetId, sheetId, headerRow)

	for _, locationData := range locationsData {
		if locationData["visible"] != "y" {
			continue
		}

		location := Location{
			ID:            locationData["ID"],
			Name:          locationData["City"],
			Position:      position.Create(c, locationData["Lat"], locationData["Lng"]),
			SpreadsheetId: locationData["Spreadsheet ID"],
			SheetId:       locationData["Sheet ID"],
		}

		locations = append(locations, location)
	}

	return
}