commit 601b79b3f2564e5959b0ab6ed7e2b7f21fb94981 Author: Tyrel Souza Date: Mon Jul 18 20:54:31 2011 -0700 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b4f2a7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.hg/ +.hgignore +*.pyc +local_settings.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logbook/__init__.py b/logbook/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/logbook/admin.py b/logbook/admin.py new file mode 100644 index 0000000..b1187b2 --- /dev/null +++ b/logbook/admin.py @@ -0,0 +1,13 @@ +from django.contrib import admin +from logbook.models import LogBookEntry, Airplane + + +class LogEntryAdmin(admin.ModelAdmin): + list_display = ('flight_date','total_duration_of_flight','airport_from','airport_to','username') + date_hierarchy = 'flight_date' +admin.site.register(LogBookEntry,LogEntryAdmin) + + +class AirplaneAdmin(admin.ModelAdmin): + list_display = ('ident', 'make','airplane_model','year') +admin.site.register(Airplane,AirplaneAdmin) diff --git a/logbook/models.py b/logbook/models.py new file mode 100644 index 0000000..f5dacca --- /dev/null +++ b/logbook/models.py @@ -0,0 +1,42 @@ +from django.db import models +from django.contrib.auth.models import User + + +# Create your models here. + +class LogBookEntry(models.Model): + username= models.ForeignKey(User, ) + flight_date = models.DateField() + plane = models.ForeignKey('Airplane') + airport_from = models.CharField(max_length=4) + airport_to = models.CharField(max_length=4) + remarks = models.TextField(null=True,blank=True) + number_instructor_app = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + number_landings = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + airplane_sel = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + airplane_mel = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + cross_country = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + day_time = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + night_time = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + actual_instrument = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + simulated_instrument = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + ground_trainer = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + dual_received = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + pilot_in_command = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True) + instructor = models.CharField(max_length=30,null=True,blank=True) + total_duration_of_flight = models.DecimalField(decimal_places=1,max_digits=3) + link = models.CharField(max_length=200,null=True,blank=True) + + def __unicode__(self): + return "Date: %s Total: %s" % (self.flight_date,self.total_duration_of_flight) + +class Airplane(models.Model): + make = models.CharField(max_length=30) + airplane_model = models.CharField(max_length=30) + year = models.CharField(max_length=4) + ident = models.CharField(max_length=6) + + def __unicode__(self): + return "%s" % (self.airplane_model) + + diff --git a/logbook/templates/logbook/flight.html b/logbook/templates/logbook/flight.html new file mode 100644 index 0000000..c890310 --- /dev/null +++ b/logbook/templates/logbook/flight.html @@ -0,0 +1,37 @@ + + + + + + +

{{log.flight_date}}

+ {% if log.make_and_model %} {{log.make_and_model}}
{% endif %} + {% if log.ident %} {{log.ident}}
{% endif %} + {% if log.airport_from %} {{log.airport_from}}
{% endif %} + {% if log.airport_to %} {{log.airport_to}}
{% endif %} + {% if log.number_instructor_app %} {{log.number_instructor_app}}
{% endif %} + {% if log.number_landings %} {{log.number_landings}}
{% endif %} + {% if log.airplane_sel %} {{log.airplane_sel}}
{% endif %} + {% if log.airplane_mel %} {{log.airplane_mel}}
{% endif %} + {% if log.cross_country %} {{log.cross_country}}
{% endif %} + {% if log.day_time %} {{log.day_time}}
{% endif %} + {% if log.night_time %} {{log.night_time}}
{% endif %} + {% if log.actual_instrument %} {{log.actual_instrument}}
{% endif %} + {% if log.simulated_instrument %} {{log.simulated_instrument}}
{% endif %} + {% if log.ground_trainer %} {{log.ground_trainer}}
{% endif %} + {% if log.dual_received %} {{log.dual_received}}
{% endif %} + {% if log.pilot_in_command %} {{log.pilot_in_command}}
{% endif %} + {% if log.total_duration_of_flight %} {{log.total_duration_of_flight}} {%endif%} + +
+
+
+ {{log.remarks}} + + + + diff --git a/logbook/templates/logbook/index.html b/logbook/templates/logbook/index.html new file mode 100644 index 0000000..0e80cc9 --- /dev/null +++ b/logbook/templates/logbook/index.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + {% for l in logs%} + + + + + + + + + + {% endfor %} + + + + + + + + + +
DateTail NumberAirport fromAirport toNumber of landingsDuration of FlightInfo
{{l.flight_date}}{{l.plane.ident}}{{l.airport_from}}{{l.airport_to}}{{l.number_landings}}{{l.total_duration_of_flight}}Info
{{total_landings}}{{total_time}}
+ + + diff --git a/logbook/templates/logbook/plane.html b/logbook/templates/logbook/plane.html new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/logbook/templates/logbook/plane.html @@ -0,0 +1 @@ +hi diff --git a/logbook/urls.py b/logbook/urls.py new file mode 100644 index 0000000..1ac6d4a --- /dev/null +++ b/logbook/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls.defaults import * + +urlpatterns = patterns('', + (r'^flight/(?P.*)/','logbook.views.flight'), + (r'^$', 'logbook.views.index'), +) diff --git a/logbook/views.py b/logbook/views.py new file mode 100644 index 0000000..3c40fd5 --- /dev/null +++ b/logbook/views.py @@ -0,0 +1,39 @@ +from django.contrib.auth.decorators import login_required +from django.shortcuts import get_object_or_404, render_to_response, redirect +from django.http import HttpResponseRedirect,HttpResponse +from django.template import RequestContext +from django.conf import settings +from django.contrib.auth.models import User +from django.template import RequestContext +from django.shortcuts import render_to_response +from django.core.context_processors import csrf + +from logbook.models import LogBookEntry + + +def index(request): + user = User.objects.get(username="tyrel") + logs = LogBookEntry.objects.order_by('flight_date').filter(username=user) + total_time = 0 + total_landings= 0 + for l in logs: + total_time += l.total_duration_of_flight + total_landings += l.number_landings + + return render_to_response('logbook/index.html', + { + 'logs':logs, + 'total_time':total_time, + 'total_landings':total_landings, + }) + + +def flight(request,flight): + log = get_object_or_404(LogBookEntry,pk=flight) + return render_to_response('logbook/flight.html', + { + 'log':log, + }) + +def goaway(request): + return HttpResponse("Go Away") diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..5e78ea9 --- /dev/null +++ b/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..f2a439c --- /dev/null +++ b/settings.py @@ -0,0 +1,73 @@ +try: + from local_settings import * +except: + DEBUG = True + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'tyrellogbook', # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } + } + +# Django settings for flight project. +import os + +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) +TIME_ZONE = 'America/New_York' +LANGUAGE_CODE = 'en-us' +SITE_ID = 1 +USE_I18N = True +USE_L10N = True +MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'public/media/') +MEDIA_URL = '/media/' +ADMIN_MEDIA_PREFIX = '/media/' +SECRET_KEY = '-u2an)@echbftmxy&2=(0uv(2h465fwq0x+k1%(+exvt@zr!z*' + +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', +) + +ROOT_URLCONF = 'flight.urls' + +TEMPLATE_DIRS = ( + # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Always use forward slashes, even on Windows. + # Don't forget to use absolute paths, not relative paths. + os.path.join(os.path.dirname(__file__),'templates') + +) + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + 'flight.logbook', +) +LOGIN_URL="/admin/" diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..f77c30d --- /dev/null +++ b/templates/404.html @@ -0,0 +1 @@ +Not Done. Quit telling me about problems. diff --git a/urls.py b/urls.py new file mode 100644 index 0000000..1151d1d --- /dev/null +++ b/urls.py @@ -0,0 +1,12 @@ +from django.conf.urls.defaults import * + +# Uncomment the next two lines to enable the admin: +from django.contrib import admin +admin.autodiscover() + +urlpatterns = patterns('', + (r'^admin/', include(admin.site.urls)), + (r'^book/', include('logbook.urls')), + (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/media/favicon.ico'}), + #(r'^$', 'logbook.views.goaway'), +)