Project for the UPV to develop an app like BlaBlaCar but only for UPV people.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fixed #22

+14 -2
+13 -1
upvcarshare/journeys/forms.py
··· 4 4 import datetime 5 5 6 6 import floppyforms 7 + import pytz 7 8 from django import forms 8 9 from django.contrib.gis.geos import GEOSGeometry 9 10 from django.core.exceptions import ObjectDoesNotExist 11 + from django.utils.timezone import make_aware 10 12 from django.utils.translation import ugettext_lazy as _ 11 13 from django.utils import timezone 12 14 ··· 227 229 raise forms.ValidationError(_("No puedes ofertar más plazas que las que tienes en el transporte")) 228 230 return free_places 229 231 230 - 231 232 def save(self, commit=True, **kwargs): 232 233 """When save a journey form, you have to provide an user.""" 233 234 user = self.user ··· 366 367 def clean_distance(self): 367 368 distance = self.cleaned_data["distance"] 368 369 return float(distance) 370 + 371 + def clean_departure_time(self): 372 + departure_date = self.cleaned_data["departure_date"] 373 + departure_time = self.cleaned_data["departure_time"] 374 + departure_datetime = make_aware( 375 + datetime.datetime.combine(departure_date, departure_time), 376 + pytz.timezone("Europe/Madrid") 377 + ) 378 + time_zone = pytz.timezone("UTC") 379 + departure_datetime = timezone.localtime(departure_datetime, time_zone) 380 + return departure_datetime.time() 369 381 370 382 def search(self, user): 371 383 position = self.cleaned_data["position"]
+1 -1
upvcarshare/journeys/tests/test_helpers.py
··· 62 62 63 63 def test_expand_september(self): 64 64 journey = JourneyFactory() 65 - journey.departure = journey.departure.replace(month=9) 65 + journey.departure = journey.departure.replace(day=1, month=9) 66 66 journey.save() 67 67 68 68 rule = recurrence.Rule(recurrence.DAILY)