changes made to db structure.. and to admin.py
This commit is contained in:
parent
ed0ab33e8a
commit
2917178fcf
BIN
chaloBEST/chalobest.db
Normal file
BIN
chaloBEST/chalobest.db
Normal file
Binary file not shown.
|
@ -4,7 +4,7 @@ from settings import PROJECT_ROOT
|
||||||
from os.path import join
|
from os.path import join
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
import sys
|
||||||
|
|
||||||
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/db_csv_files/AreaMaster.csv", "r"))
|
CsvFile = csv.reader(open("/home/johnson/Desktop/chaloBEST/db_csv_files/AreaMaster.csv", "r"))
|
||||||
CsvFile.next()
|
CsvFile.next()
|
||||||
|
@ -97,29 +97,61 @@ for entry in CsvFile:
|
||||||
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def Depot_loader():
|
||||||
CsvFile = csv.reader(open(join(PROJECT_ROOT, "../db_csv_files/Depot.csv"), "r"), delimiter="\t")
|
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')
|
f= open(join(PROJECT_ROOT, "../db_csv_files/DepotErrors.csv"), 'w')
|
||||||
test = CsvFile.next()
|
header = CsvFile.next()
|
||||||
print test
|
print header
|
||||||
for entry in CsvFile:
|
for entry in CsvFile:
|
||||||
try:
|
try:
|
||||||
date_format = entry[0].rsplit('.')
|
obj = Depot(depot_code=str(entry[0]),depot_name=str(entry[1]), stop = Stop.objects.get(stopcd=int(entry[2])))
|
||||||
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.save()
|
obj.save()
|
||||||
obj.__dict__
|
obj.__dict__
|
||||||
except :
|
except :
|
||||||
f.write(str(sys.exc_info()[0]) + str(entry) + '\n')
|
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()
|
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
|
RouteTypes
|
||||||
|
|
|
@ -38,7 +38,7 @@ class StopAdmin(admin.ModelAdmin):
|
||||||
list_editable = ("stopnm", "roadcd","a_code","stopfl","depot","chowki")
|
list_editable = ("stopnm", "roadcd","a_code","stopfl","depot","chowki")
|
||||||
search_fields = ("stopcd",'stopnm', 'depot')
|
search_fields = ("stopcd",'stopnm', 'depot')
|
||||||
ordering = ('stopnm',)
|
ordering = ('stopnm',)
|
||||||
list_per_page = 50
|
list_per_page = 20
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(None, {
|
(None, {
|
||||||
|
@ -58,35 +58,59 @@ class StopAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class RouteDetailsAdmin(admin.ModelAdmin):
|
class RouteDetailsAdmin(admin.ModelAdmin):
|
||||||
list_display = ("rno","stopsr","stopcd","stage","km")
|
list_display = ("rno","stopsr","stopcd","stage","km")
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RouteAdmin(admin.ModelAdmin):
|
class RouteAdmin(admin.ModelAdmin):
|
||||||
list_display = ("routealias","route","from_stop","to_stop","distance","stages")
|
list_display = ("routealias","route","from_stop","to_stop","distance","stages")
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RouteTypesAdmin(admin.ModelAdmin):
|
class RouteTypesAdmin(admin.ModelAdmin):
|
||||||
list_display = ("routecode","routetype","faretype")
|
list_display = ("routecode","routetype","faretype")
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class HardCodedRoutesAdmin(admin.ModelAdmin):
|
class HardCodedRoutesAdmin(admin.ModelAdmin):
|
||||||
list_display = ("routecode","routealias","faretype")
|
list_display = ("routecode","routealias","faretype")
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
class LandmarkAdmin(admin.ModelAdmin):
|
class LandmarkAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "name_mr")
|
list_display = ("name", "name_mr")
|
||||||
list_editable = ("name_mr",)
|
list_editable = ("name_mr",)
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
class StopLocationAdmin(admin.ModelAdmin):
|
class StopLocationAdmin(admin.ModelAdmin):
|
||||||
list_display = ("stop", "direction")
|
list_display = ("stop", "direction")
|
||||||
#list_editable = ("name","name_mr")
|
#list_editable = ("name","name_mr")
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
class DepotAdmin(admin.ModelAdmin):
|
class DepotAdmin(admin.ModelAdmin):
|
||||||
list_display = ("depot_code", "depot_name", "stop")
|
list_display = ("depot_code", "depot_name", "stop")
|
||||||
list_editable = ("depot_name",)
|
list_editable = ("depot_name",)
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class HolidayAdmin(admin.ModelAdmin):
|
class HolidayAdmin(admin.ModelAdmin):
|
||||||
list_display = ("h_date", "h_name")
|
list_display = ("h_date", "h_name")
|
||||||
list_editable = ("h_name",)
|
list_editable = ("h_name",)
|
||||||
|
formfield_overrides = {
|
||||||
|
models.TextField: {'widget': forms.TextInput},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user