changes made to db structure.. and to admin.py

This commit is contained in:
Johnson Chetty 2011-12-28 01:21:20 +05:30
parent ed0ab33e8a
commit 2917178fcf
3 changed files with 68 additions and 12 deletions

BIN
chaloBEST/chalobest.db Normal file

Binary file not shown.

View File

@ -4,7 +4,7 @@ from settings import PROJECT_ROOT
from os.path import join
import json
import datetime
import sys
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/db_csv_files/AreaMaster.csv", "r"))
CsvFile.next()
@ -97,29 +97,61 @@ for entry in CsvFile:
f.close()
def Depot_loader():
CsvFile = csv.reader(open(join(PROJECT_ROOT, "../db_csv_files/Depot.csv"), "r"), delimiter="\t")
f= open(join(PROJECT_ROOT, "../db_csv_files/Depot.csv"), 'w')
test = CsvFile.next()
print test
f= open(join(PROJECT_ROOT, "../db_csv_files/DepotErrors.csv"), 'w')
header = CsvFile.next()
print header
for entry in CsvFile:
try:
date_format = entry[0].rsplit('.')
theday = int(date_format[0])
themonth = int(date_format[1])
theyear = int('20'+ date_format[2])
obj = Holiday(h_date=datetime.date(day=theday, month=themonth, year=theyear), h_name=str(entry[1]))
obj = Depot(depot_code=str(entry[0]),depot_name=str(entry[1]), stop = Stop.objects.get(stopcd=int(entry[2])))
obj.save()
obj.__dict__
except :
f.write(str(sys.exc_info()[0]) + str(entry) + '\n')
print "Error:", sys.exc_info()[0]
print "Error:", sys.exc_info()[0] + str(entry)
f.close()
CsvFile = csv.reader(open(join(PROJECT_ROOT, "../db_csv_files/StopMarathi.csv"), "r"), delimiter="\t")
f= open(join(PROJECT_ROOT, "../db_csv_files/StopMarathiErrors.csv"), 'w')
header = CsvFile.next()
print header
for entry in CsvFile:
try:
obj = Stop.objects.get(stopcd=int(entry[0]))
obj.stopnm_mr = str(entry[1])
obj.save()
obj.__dict__
except:
f.write(str(sys.exc_info()[0]) + str(entry) + '\n')
print "Error:", sys.exc_info()[0], str(entry)
f.close()
CsvFile = csv.reader(open(join(PROJECT_ROOT, "../db_csv_files/AreaMarathi.csv"), "r"), delimiter="\t")
f= open(join(PROJECT_ROOT, "../db_csv_files/AreaMarathiErrors.csv"), 'w')
header = CsvFile.next()
print header
for entry in CsvFile:
try:
obj = Area.objects.get(a_code=int(entry[0]))
obj.areanm_mr = str(entry[1])
obj.save()
obj.__dict__
except:
f.write(str(sys.exc_info()[0]) + str(entry) + '\n')
print "Error:", sys.exc_info()[0], str(entry)
f.close()
RouteTypes

View File

@ -38,7 +38,7 @@ class StopAdmin(admin.ModelAdmin):
list_editable = ("stopnm", "roadcd","a_code","stopfl","depot","chowki")
search_fields = ("stopcd",'stopnm', 'depot')
ordering = ('stopnm',)
list_per_page = 50
list_per_page = 20
fieldsets = (
(None, {
@ -58,35 +58,59 @@ class StopAdmin(admin.ModelAdmin):
class RouteDetailsAdmin(admin.ModelAdmin):
list_display = ("rno","stopsr","stopcd","stage","km")
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class RouteAdmin(admin.ModelAdmin):
list_display = ("routealias","route","from_stop","to_stop","distance","stages")
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class RouteTypesAdmin(admin.ModelAdmin):
list_display = ("routecode","routetype","faretype")
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class HardCodedRoutesAdmin(admin.ModelAdmin):
list_display = ("routecode","routealias","faretype")
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class LandmarkAdmin(admin.ModelAdmin):
list_display = ("name", "name_mr")
list_editable = ("name_mr",)
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class StopLocationAdmin(admin.ModelAdmin):
list_display = ("stop", "direction")
#list_editable = ("name","name_mr")
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class DepotAdmin(admin.ModelAdmin):
list_display = ("depot_code", "depot_name", "stop")
list_editable = ("depot_name",)
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}
class HolidayAdmin(admin.ModelAdmin):
list_display = ("h_date", "h_name")
list_editable = ("h_name",)
formfield_overrides = {
models.TextField: {'widget': forms.TextInput},
}