Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

pep8

  • Loading branch information...
commit 15f93684a0cb9bfb880c6f9856ea2fba50ecc45a 1 parent 5a52571
mjbecze@gmail.com authored
7 occupywallst/media/css/rideshare.css
@@ -5,10 +5,3 @@
5 5 text-align: left;
6 6 }
7 7
8   -.paginate_enabled_previous { background: url('../img/back_enabled.png') no-repeat top left; }
9   -.paginate_enabled_previous:hover { background: url('../img/back_enabled_hover.png') no-repeat top left; }
10   -.paginate_disabled_previous { background: url('../img/back_disabled.png') no-repeat top left; }
11   -
12   -.paginate_enabled_next { background: url('../img/forward_enabled.png') no-repeat top right; }
13   -.paginate_enabled_next:hover { background: url('../img/forward_enabled_hover.png') no-repeat top right; }
14   -.paginate_disabled_next { background: url('../img/forward_disabled.png') no-repeat top right; }
22 occupywallst/media/js/occupywallst/rides.js
@@ -411,26 +411,4 @@ var rides_init;
411 411 }
412 412 // export stuff
413 413 rides_init = init;
414   -
415 414 })();
416   -
417   -
418   -//this shit is for ride edit
419   -$(function(){
420   -
421   -var date = new Date('2012', '04', '15');
422   -
423   -$("#id_depart_time").datepicker({ dateFormat: 'yy-mm-dd',
424   - defaultDate: '2012-05-15' });
425   -
426   -$("#id_return_time").datepicker({ dateFormat: 'yy-mm-dd',
427   - defaultDate: '2012-05-22' });
428   -$("#id_ride_direction").change(function(){
429   - if($(this).val() != 'round'){
430   - $('#id_return_time').closest('tr').hide();
431   - }else{
432   - $('#id_return_time').closest('tr').show();
433   - }
434   - });
435   -});
436   -
2  occupywallst/views.py
@@ -322,7 +322,7 @@ def signup(request):
322 322 form = forms.SignupForm(request.POST)
323 323 if form.is_valid():
324 324 key = 'signup_' + request.META['REMOTE_ADDR']
325   - if cache.get(key):
  325 + if cache.get(key) and not settings.DEBUG:
326 326 return HttpResponse('please wait before signing up again')
327 327 cache.set(key, True, settings.OWS_LIMIT_SIGNUP)
328 328 form.save()
3  rideshare/forms.py
@@ -48,11 +48,8 @@ def __init__(self, *args, **kwargs):
48 48 def save(self, commit=True):
49 49 from django.contrib.gis.geos import GEOSGeometry
50 50 model = super(RideForm, self).save(commit=False)
51   -
52 51 points = GEOSGeometry(self.cleaned_data['waypoints_points_wkt'])
53   - #pdb.set_trace()
54 52 model.waypoints_points = points
55   -
56 53 if self.cleaned_data['waypoints'] != '':
57 54 self.cleaned_data['waypoints'] = \
58 55 self.cleaned_data['waypoints'] + '\n'
19 rideshare/models.py
@@ -4,6 +4,7 @@
4 4 from django.core.exceptions import ObjectDoesNotExist
5 5
6 6 from occupywallst import geo
  7 +from rideshare import settings
7 8
8 9
9 10 class Ride(models.Model):
@@ -13,7 +14,7 @@ class Ride(models.Model):
13 14 ('bus', 'Bus'),
14 15 ('other', 'Other'),
15 16 )
16   - #this is defined twice?
  17 + #this is defined twice, other in RideRequest
17 18 RIDEDIR_CHOICES = (
18 19 ('round', 'Round Trip'),
19 20 ('to', 'One Way too'),
@@ -34,9 +35,19 @@ class Ride(models.Model):
34 35 What type of vehicle is being offered?""")
35 36 title = models.CharField(max_length=255, help_text="""
36 37 A one-line title to describe ride.""")
37   - depart_time = models.DateTimeField(default="2012-05-15", help_text="""
  38 + if hasattr(settings, 'DEFUALT_DEPART_DATE'):
  39 + default_depart_time = settings.DEFUALT_DEPART_DATE
  40 + else:
  41 + default_depart_time = None
  42 +
  43 + depart_time = models.DateTimeField(default=default_depart_time, help_text="""
38 44 What time are you leaving?""")
39   - return_time = models.DateTimeField(default="2012-05-22", help_text="""
  45 +
  46 + if hasattr(settings, 'DEFUALT_RETURN_DATE'):
  47 + default_return_time = settings.DEFUALT_DEPART_DATE
  48 + else:
  49 + default_return_time = None
  50 + return_time = models.DateTimeField(default=default_return_time, help_text="""
40 51 What time are you coming back?""")
41 52 seats_total = models.IntegerField(default=0, help_text="""
42 53 How many seats in vehicle does the user wish to fill?""")
@@ -79,7 +90,7 @@ def accepted_requests(self):
79 90 def forum_title(self):
80 91 waypoints = self.waypoint_list
81 92 return "%s to %s on %s" % (
82   - waypoints[0], waypoints[-1], self.depart_time.date())
  93 + waypoints[0], waypoints[-1], self.depart_time.date())
83 94
84 95 def retrieve_route_from_google(self):
85 96 route = geo.directions(self.waypoint_list)
3  rideshare/settings.py
@@ -10,3 +10,6 @@
10 10 DEFAULT_CITY = "New York, NY"
11 11 DEFAULT_LOCATION = [40.744136, -73.989487]
12 12 DEFAULT_END_ADDRESS = "Wall Street, NYC"
  13 +
  14 +#DEFUALT_DEPART_DATE = "2012-05-22"
  15 +#DEFUALT_RETURN_DATE = "2012-05-22"
3  rideshare/templates/ride_base.html
@@ -4,9 +4,6 @@
4 4 {% block body_class %}rides-page{% endblock %}
5 5 {% block scripts %}
6 6 <script src="//maps.google.com/maps/api/js?libraries=places&sensor=false&region=us" type="text/javascript"></script>
7   - <script src="//maps.google.com/maps/api/js?libraries=places&sensor=false&region=us" type="text/javascript"></script>
8   - <script src="{{ MEDIA_URL }}js/jquery-ui-1.8.17.custom.min.js" type="text/javascript"></script>
9   - <script src="{{ MEDIA_URL }}js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
10 7 <script src="{{ MEDIA_URL }}js/jquery.dataTables.min.js" type="text/javascript"></script>
11 8 {% endblock scripts %}
12 9
16 rideshare/templates/ride_update.html
... ... @@ -1,10 +1,12 @@
1   -{% extends base %}
  1 +{% extends "ride_base.html" %}
2 2 {% block body_class %}rides-page rides-update-page{% endblock %}
3 3 {% block title %}Free Bus/Carpool Route Map | {{ OWS_SITE_NAME }}{% endblock title %}
4 4
5 5 {% block scripts %}
  6 + {{ block.super }}
  7 + <script src="{{ MEDIA_URL }}js/jquery-ui-1.8.17.custom.min.js" type="text/javascript"></script>
  8 + <script src="{{ MEDIA_URL }}js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
6 9 <link type="text/css" href="{{ MEDIA_URL }}css/custom-theme/jquery-ui-1.8.23.custom.css" rel="Stylesheet" />
7   - <script src="//maps.google.com/maps/api/js?libraries=places&sensor=false&region=us" type="text/javascript"></script>
8 10 {% endblock scripts %}
9 11
10 12 {% block js_init %}
@@ -20,6 +22,16 @@
20 22 "rendezvous":[{% for request in requests %}[{{request.rendezvous.0}},{{request.rendezvous.1}},"{{request.rendezvous_address}}","{{request.user}}"],{%endfor%}],
21 23 {% endif %}
22 24 });
  25 +
  26 + $("#id_depart_time").datepicker({ dateFormat: 'yy-mm-dd'});
  27 + $("#id_return_time").datepicker({ dateFormat: 'yy-mm-dd'});
  28 + $("#id_ride_direction").change(function(){
  29 + if($(this).val() != 'round'){
  30 + $('#id_return_time').closest('tr').hide();
  31 + }else{
  32 + $('#id_return_time').closest('tr').show();
  33 + }
  34 + });
23 35 {% endblock js_init %}
24 36
25 37 {% block content %}
14 rideshare/templates/rides.html
@@ -60,10 +60,10 @@
60 60 <tr>
61 61 <th>Ride</th>
62 62 <th>Description</th>
63   - <th>Start</th>
64   - <th>Date</th>
65   - <th>End</th>
66   - <th>Date</th>
  63 + <th>Start Location</th>
  64 + <th>Destination</th>
  65 + <th>Arrival&nbsp;Date</th>
  66 + <th>Return&nbsp;Date</th>
67 67 </tr>
68 68 </thead>
69 69 <tbody>
@@ -71,10 +71,10 @@
71 71 <tr>
72 72 <td><a href="{% url ride_info ride.id %}" >{{ride.title}}</a></td>
73 73 <td>{{ ride.info|slice:":29"}}{% if ride.info|length > 30 %}...{% endif %}</td>
74   - <td>{{ride.waypoint_list.1}}</td>
  74 + <td>{{ride.waypoint_list.0}}</td>
  75 + <td>{{ride.waypoint_list|last}}</td>
75 76 <td>{{ride.depart_time|date:"SHORT_DATE_FORMAT"}}</td>
76   - <td>{{ride.waypoint_list|last}}</td>
77   - <td>{{ride.return_time|date:"SHORT_DATE_FORMAT"}}</td>
  77 + <td>{% if ride.ride_direction == "round" %} {{ride.return_time|date:"SHORT_DATE_FORMAT"}} {% endif %}</td>
78 78 </tr>
79 79 {% endfor %}
80 80 </tbody>
13 rideshare/views.py
@@ -71,8 +71,8 @@ def ride_delete(request, ride_id):
71 71 requests = ride.requests.all()
72 72 for req in requests:
73 73 maindb.Notification.send(
74   - req.user, reverse('rides'),
75   - '%s has deleted there ride' % (ride.user.username))
  74 + req.user, reverse('rides'),
  75 + '%s has deleted there ride' % (ride.user.username))
76 76 requests.delete()
77 77 ride.delete()
78 78 return HttpResponseRedirect(reverse(rides))
@@ -113,9 +113,13 @@ def ride_create_or_update(request, instance=None):
113 113 ride_requests = None
114 114 else:
115 115 userinfo = maindb.UserInfo.objects.get(user=request.user)
  116 + if hasattr(settings, 'DEFAULT_END_ADDRESS'):
  117 + default_end_address = settings.DEFAULT_END_ADDRESS
  118 + else:
  119 + default_end_address = None
116 120 form = forms.RideForm(initial={
117 121 'start_address': userinfo.formatted_address,
118   - 'end_address': settings.DEFAULT_END_ADDRESS,
  122 + 'end_address': default_end_address,
119 123 }, instance=instance)
120 124 ride_requests = db.RideRequest.objects.filter(ride=instance)
121 125 return render_to_response('ride_update.html', {
@@ -206,11 +210,10 @@ def rides_get(bounds=None, **kwargs):
206 210 .filter(route__isnull=False))
207 211 for ride in qset:
208 212 yield {'id': ride.id,
209   - 'title':ride.title,
  213 + 'title': ride.title,
210 214 'address': ride.waypoint_list[0],
211 215 'route': ride.route}
212 216
213   -
214 217 def ride_request_update(request_id, status, user=None, **kwargs):
215 218 ride_request = (db.RideRequest.objects
216 219 .select_related("ride", "ride__user")

0 comments on commit 15f9368

Please sign in to comment.
Something went wrong with that request. Please try again.