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.

minor changes on notifications

+41 -4
+1 -1
upvcarshare/journeys/models.py
··· 303 303 return self.name 304 304 305 305 def description(self): 306 - return ", ".join([self.brand, self.model, self.color]) 306 + return " ".join([self.brand, self.model, self.color]) 307 307 308 308 def count_used_journeys(self): 309 309 return self.journeys.count()
+2
upvcarshare/journeys/templatetags/journeys_tags.py
··· 18 18 @register.inclusion_tag('journeys/templatetags/join_leave_button.html', takes_context=True) 19 19 def journey_join_leave_button(context, journey): 20 20 """Renders a journey as an item list.""" 21 + request = context["request"] 21 22 context["journey_item"] = journey 23 + context["passenger"] = journey.passengers.filter(user=request.user).first() 22 24 return context 23 25 24 26
+17 -1
upvcarshare/notifications/manager.py
··· 5 5 from django.db import models 6 6 from django.utils.functional import SimpleLazyObject 7 7 8 - from notifications import LEAVE, JOIN, CANCEL, MESSAGE 8 + from notifications import LEAVE, JOIN, CANCEL, MESSAGE, REJECT, CONFIRM 9 9 10 10 11 11 def extract(classes, iterable): ··· 32 32 journey = extract(Journey, objects)[0] 33 33 notification.user = journey.user 34 34 notification.actor = actor 35 + notification.target = journey 36 + notification.save() 37 + return notification 38 + 39 + def _create_confirm_reject(self, **kwargs): 40 + """Creates notification for a join or leave journey.""" 41 + from journeys.models import Journey 42 + verb = kwargs.get("verb") 43 + objects = kwargs.get("objects") 44 + notification = self.model(verb=verb) 45 + actor = extract([get_user_model(), SimpleLazyObject], objects)[0] 46 + journey = extract(Journey, objects)[0] 47 + notification.user = actor 48 + notification.actor = journey.user 35 49 notification.target = journey 36 50 notification.save() 37 51 return notification ··· 99 113 # User ('actor') leaves|joins ('verb') journey ('target') 100 114 if verb in (JOIN, LEAVE): 101 115 return self._create_join_leave(verb=verb, objects=objects) 116 + elif verb in (CONFIRM, REJECT): 117 + return self._create_confirm_reject(verb=verb, objects=objects) 102 118 elif verb == CANCEL: 103 119 return self._create_cancel(verb=verb, objects=objects) 104 120 elif verb == MESSAGE:
+13 -1
upvcarshare/notifications/models.py
··· 13 13 from django.utils.translation import ugettext_lazy as _ 14 14 from django_extensions.db.models import TimeStampedModel 15 15 16 - from notifications import JOIN, LEAVE, CANCEL, MESSAGE 16 + from notifications import JOIN, LEAVE, CANCEL, MESSAGE, CONFIRM, REJECT 17 17 from notifications.manager import NotificationManager 18 18 19 19 ··· 67 67 } 68 68 elif self.verb == LEAVE: 69 69 value = _("%(user)s ha <strong>abandonado</strong> el trayecto <strong>%(journey)s</strong> del %(date)s") % { 70 + "user": six.text_type(self.actor), 71 + "journey": six.text_type(self.target).lower(), 72 + "date": localize(self.target.departure), 73 + } 74 + elif self.verb == CONFIRM: 75 + value = _("%(user)s te ha <strong>confirmado</strong> para el trayecto <strong>%(journey)s</strong> del %(date)s") % { 76 + "user": six.text_type(self.actor), 77 + "journey": six.text_type(self.target).lower(), 78 + "date": localize(self.target.departure), 79 + } 80 + elif self.verb == REJECT: 81 + value = _("%(user)s te ha <strong>rechazado</strong> para el trayecto <strong>%(journey)s</strong> del %(date)s") % { 70 82 "user": six.text_type(self.actor), 71 83 "journey": six.text_type(self.target).lower(), 72 84 "date": localize(self.target.departure),
+1
upvcarshare/templates/journeys/templatetags/item.html
··· 2 2 {% load core_tags %} 3 3 {% load journeys_tags %} 4 4 {% load humanize %} 5 + 5 6 <div class="journey-item {% if journey_item.disabled %}journey-item-disabled{% endif %}"> 6 7 <div class="row"> 7 8 <div class="col-sm-3 map">
+7 -1
upvcarshare/templates/journeys/templatetags/join_leave_button.html
··· 5 5 {% csrf_token %} 6 6 <input type="hidden" name="return_to" value="{{ request.path }}"> 7 7 {% if journey_item.disabled or passenger.status == UNKNOWN or passenger.status == REJECTED %} 8 - <button type="button" disabled="disabled" class="btn btn-secondary">{% trans "Unirse" %}</button> 8 + {% if passenger.status == UNKNOWN %} 9 + <button type="button" disabled="disabled" class="btn btn-secondary">{% trans "Esperando confirmación" %}</button> 10 + {% elif passenger.status == REJECTED %} 11 + <button type="button" disabled="disabled" class="btn btn-secondary">{% trans "Rechazado" %}</button> 12 + {% else %} 13 + <button type="button" disabled="disabled" class="btn btn-secondary">{% trans "Unirse" %}</button> 14 + {% endif %} 9 15 {% else %} 10 16 <button type="submit" class="btn btn-success">{% trans "Unirse" %}</button> 11 17 {% endif %}