Juarez Bochi avatar Juarez Bochi committed 30e0c36

Added page for flights

Comments (0)

Files changed (3)

         self.get_by_event_type(iata_code, departure=True)
 
 
+class FlightPage(EventHandler):
+    def get(self, iata_code, departure_or_arrival, flight_number):
+        airport = Airport.all().filter('iata_code =', iata_code).get()
+
+        if departure_or_arrival == 'partidas':
+            departure = True
+            query = Departure.all().filter('source =', airport)
+        elif  departure_or_arrival == 'chegadas':
+            departure = False
+            query = Arrival.all().filter('destination =', airport)
+        else:
+            self.error(404)
+            return
+
+        event = query.filter('flight_number =', flight_number).order('-date').get()
+        template_values = {'airport': airport,
+                           'event': event,
+                           'departure': departure}
+
+        self.render_template('flight.html', template_values)
+
 application = webapp.WSGIApplication([('/', MainPage),
                                       ('/(\w*)/$', AirportPage),
                                       ('/(\w*)/partidas/', DeparturesPage),
                                       ('/(\w*)/chegadas/', ArrivalsPage),
+                                      ('/(\w*)/(\w*)/(\d*)/', FlightPage),
                                       ], debug=True)
 
 
   - name: date
   - name: source
   - name: confirmed
+
+- kind: Event
+  properties:
+  - name: class
+  - name: destination
+  - name: flight_number
+  - name: date
+    direction: desc

src/templates/panel.html

                 <th>Confirmado</th>
                 <th>{% if departure %}Destino{% else %}Origem{% endif %}</th>
                 <th>Status</th>
+                <th>Detalhes</th>
             </tr>
         </thead>
         <tbody>
                             {% endif %}
                         </td>                        
                         <td class="status">{{ event.status }}</td>
+                        <td>
+                            <a data-role="button"
+                               data-inline="true" 
+                               data-icon="info"
+                               data-iconpos="notext"
+                               href="{{ event.flight_number }}/">Info</a>
+                        </td>
                     </tr>
                 {% endfor %}
             {% else %}
                 <tr>
-                    <td colspan="6">Nenhum voo encontrado</td>
+                    <td colspan="7">Nenhum voo encontrado</td>
                 </tr>
             {% endif %}
         </tbody>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.