Created
September 14, 2012 06:51
-
-
Save osiro/3720288 to your computer and use it in GitHub Desktop.
Venue Model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class @Venue extends Spine.Model | |
@configure 'Venue', 'address', 'advertUrl', 'email', 'logo', 'latitude', 'longitude', 'name', | |
'phoneNumber', 'website', 'shortDescription', 'longDescription', | |
'openingHours', 'capacity', 'distance' | |
@extend Spine.Model.Local | |
@belongsTo 'venueType', 'VenueType' | |
@findByIds: (ids) -> | |
@ids = ids | |
Venue.select (venue) => | |
$.inArray("#{venue.id}", @ids) > -1 | |
@capacitySort: (v1, v2) -> | |
parseFloat(v2.capacity.overall.live) - parseFloat(v1.capacity.overall.live) | |
@calculateDistanceFromCurrentLocation: (venues) -> | |
for venue in venues | |
distance = maps.calculateDistance(new google.maps.LatLng(venue.latitude, venue.longitude)) | |
venue.updateAttribute 'distance', distance | |
@distanceSort: (v1, v2) -> | |
parseFloat(v1.distance) - parseFloat(v2.distance) | |
@nameSort: (v1, v2) -> | |
if v1.name > v2.name then 1 | |
else if v1.name == v2.name then 0 | |
else -1 | |
statsFor: (category, day) => | |
@["capacity"][category][day.toLowerCase()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment