added tem table for location data
This commit is contained in:
117
rog/admin.py
117
rog/admin.py
@ -2,7 +2,7 @@ from django.contrib import admin
|
||||
from leaflet.admin import LeafletGeoAdmin
|
||||
from leaflet.admin import LeafletGeoAdminMixin
|
||||
from leaflet_admin_list.admin import LeafletAdminListMixin
|
||||
from .models import RogUser, Location, SystemSettings, JoinedEvent, Favorite, TravelList, TravelPoint, ShapeLayers, Event, Location_line, Location_polygon, JpnAdminMainPerf, JpnAdminPerf, JpnSubPerf, Useractions, CustomUser, GifuAreas, UserTracks, ShapeFileLocations
|
||||
from .models import RogUser, Location, SystemSettings, JoinedEvent, Favorite, TravelList, TravelPoint, ShapeLayers, Event, Location_line, Location_polygon, JpnAdminMainPerf, JpnAdminPerf, JpnSubPerf, Useractions, CustomUser, GifuAreas, UserTracks, ShapeFileLocations, templocation
|
||||
from django.contrib.auth.admin import UserAdmin
|
||||
|
||||
class RogAdmin(LeafletAdminListMixin, LeafletGeoAdminMixin, admin.ModelAdmin):
|
||||
@ -32,10 +32,120 @@ class UserAdminConfig(UserAdmin):
|
||||
(None, {'classes':('wide',), 'fields':('email','password1', 'password2')}),
|
||||
)
|
||||
|
||||
admin.site.register(Useractions)
|
||||
class LocationAdmin(LeafletGeoAdmin):
|
||||
search_fields = ('location_id', 'cp', 'location_name', 'category', 'event_name',)
|
||||
list_filter = ('category', 'event_name',)
|
||||
ordering = ('location_id', 'cp',)
|
||||
list_display = ('location_id','cp', 'location_name', 'category', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',)
|
||||
|
||||
|
||||
def tranfer_to_location(modeladmin, request, queryset):
|
||||
tmp_locs = templocation.objects.all();
|
||||
for l in tmp_locs :
|
||||
found = Location.objects.filter(location_id = l.location_id).exists()
|
||||
if found:
|
||||
Location.objects.filter(location_id = l.location_id).update(
|
||||
sub_loc_id = l.sub_loc_id,
|
||||
cp = l.cp,
|
||||
location_name = l.location_name,
|
||||
category = l.category,
|
||||
subcategory = l.subcategory,
|
||||
zip = l.zip,
|
||||
address = l.address,
|
||||
prefecture = l.prefecture,
|
||||
area = l.area,
|
||||
city = l.city,
|
||||
latitude = l.latitude,
|
||||
longitude = l.longitude,
|
||||
photos = l.photos,
|
||||
videos = l.videos,
|
||||
webcontents = l.webcontents,
|
||||
status = l.status,
|
||||
portal = l.portal,
|
||||
group = l.group,
|
||||
phone = l.phone,
|
||||
fax = l.fax,
|
||||
email = l.email,
|
||||
facility = l.facility,
|
||||
remark = l.remark,
|
||||
tags = l.tags,
|
||||
hidden_location = l.hidden_location,
|
||||
auto_checkin = l.auto_checkin,
|
||||
checkin_radius = l.checkin_radius,
|
||||
checkin_point = l.checkin_point,
|
||||
buy_point = l.buy_point,
|
||||
evaluation_value = l.evaluation_value,
|
||||
shop_closed = l.shop_closed,
|
||||
shop_shutdown = l.shop_shutdown,
|
||||
opening_hours_mon = l.opening_hours_mon,
|
||||
opening_hours_tue = l.opening_hours_tue,
|
||||
opening_hours_wed = l.opening_hours_wed,
|
||||
opening_hours_thu = l.opening_hours_thu,
|
||||
opening_hours_fri = l.opening_hours_fri,
|
||||
opening_hours_sat = l.opening_hours_sat,
|
||||
opening_hours_sun = l.opening_hours_sun,
|
||||
geom=l.geom
|
||||
)
|
||||
else:
|
||||
loc = Location(
|
||||
location_id=l.location_id,
|
||||
sub_loc_id = l.sub_loc_id,
|
||||
cp = l.cp,
|
||||
location_name = l.location_name,
|
||||
category = l.category,
|
||||
subcategory = l.subcategory,
|
||||
zip = l.zip,
|
||||
address = l.address,
|
||||
prefecture = l.prefecture,
|
||||
area = l.area,
|
||||
city = l.city,
|
||||
latitude = l.latitude,
|
||||
longitude = l.longitude,
|
||||
photos = l.photos,
|
||||
videos = l.videos,
|
||||
webcontents = l.webcontents,
|
||||
status = l.status,
|
||||
portal = l.portal,
|
||||
group = l.group,
|
||||
phone = l.phone,
|
||||
fax = l.fax,
|
||||
email = l.email,
|
||||
facility = l.facility,
|
||||
remark = l.remark,
|
||||
tags = l.tags,
|
||||
hidden_location = l.hidden_location,
|
||||
auto_checkin = l.auto_checkin,
|
||||
checkin_radius = l.checkin_radius,
|
||||
checkin_point = l.checkin_point,
|
||||
buy_point = l.buy_point,
|
||||
evaluation_value = l.evaluation_value,
|
||||
shop_closed = l.shop_closed,
|
||||
shop_shutdown = l.shop_shutdown,
|
||||
opening_hours_mon = l.opening_hours_mon,
|
||||
opening_hours_tue = l.opening_hours_tue,
|
||||
opening_hours_wed = l.opening_hours_wed,
|
||||
opening_hours_thu = l.opening_hours_thu,
|
||||
opening_hours_fri = l.opening_hours_fri,
|
||||
opening_hours_sat = l.opening_hours_sat,
|
||||
opening_hours_sun = l.opening_hours_sun,
|
||||
geom=l.geom
|
||||
)
|
||||
loc.save()
|
||||
tranfer_to_location.short_description = "Transfer all locations in temp table to location table"
|
||||
|
||||
|
||||
class TempLocationAdmin(LeafletGeoAdmin):
|
||||
search_fields = ('location_id', 'cp', 'location_name', 'category', 'event_name',)
|
||||
list_filter = ('category', 'event_name',)
|
||||
ordering = ('location_id', 'cp',)
|
||||
list_display = ('location_id','cp', 'location_name', 'category', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',)
|
||||
actions = [tranfer_to_location,]
|
||||
|
||||
|
||||
|
||||
admin.site.register(Useractions)
|
||||
admin.site.register(RogUser, admin.ModelAdmin)
|
||||
admin.site.register(Location, LeafletGeoAdmin)
|
||||
admin.site.register(Location, LocationAdmin)
|
||||
admin.site.register(SystemSettings, admin.ModelAdmin)
|
||||
admin.site.register(JoinedEvent, admin.ModelAdmin)
|
||||
admin.site.register(Favorite, admin.ModelAdmin)
|
||||
@ -53,3 +163,4 @@ admin.site.register(ShapeLayers, admin.ModelAdmin)
|
||||
#admin.site.register(ShapeFileLocations, admin.ModelAdmin)
|
||||
|
||||
admin.site.register(CustomUser, UserAdminConfig)
|
||||
admin.site.register(templocation, TempLocationAdmin)
|
||||
|
||||
Reference in New Issue
Block a user