mirror of
https://github.com/bspeice/UNCCGameDay-Server
synced 2024-12-04 13:58:14 -05:00
Add some more skeleton to the Parking system
Does contain some *basic* implementation
This commit is contained in:
parent
726ad4ca70
commit
269795202d
@ -48,6 +48,23 @@ class ParkingLot(models.Model):
|
||||
location = models.CharField(choices=LOT_CHOICES, unique=True,
|
||||
primary_key=True)
|
||||
# parkingrating_set
|
||||
|
||||
@property
|
||||
def current_ratings(self):
|
||||
# Return a QuerySet containing only valid ParkingRatings
|
||||
# (those ratings that aren't from a previous gameday)
|
||||
return self.parkingrating_set.all()
|
||||
|
||||
def get_rating(self):
|
||||
# Get the current rating of this parking lot
|
||||
NUM_LOTS = 10
|
||||
if self.current_ratings.count() < NUM_LOTS:
|
||||
# Probably raise an exception here, not enough responses yet
|
||||
pass
|
||||
else:
|
||||
total = sum([ ParkingRating.RATING_WEIGHTS[r.rating]
|
||||
for r in self.parkingrating_set.all().order_by('created')[0:10] ])
|
||||
return total / NUM_LOTS
|
||||
|
||||
class ParkingRating(models.Model):
|
||||
|
||||
@ -61,7 +78,13 @@ class ParkingRating(models.Model):
|
||||
(RATING_BUSY, 'Busy'),
|
||||
(RATING_FULL, 'Full'),
|
||||
)
|
||||
RATING_WEIGHTS = {
|
||||
RATING_EMPTY: 0,
|
||||
RATING_SCATTERED: 33,
|
||||
RATING_BUSY: 66,
|
||||
RATING_FULL: 100,
|
||||
}
|
||||
|
||||
rating = models.CharField(max_length=10, choices=RATING_CHOICES)
|
||||
created = models.DateTimeField(default=datetime.datetime.now)
|
||||
parking_lot = models.ForeignKey(ParkingLot)
|
||||
parking_lot = models.ForeignKey(ParkingLot)
|
||||
|
Loading…
Reference in New Issue
Block a user