update for city admin
This commit is contained in:
10
rog/admin.py
10
rog/admin.py
@ -32,11 +32,17 @@ class UserAdminConfig(UserAdmin):
|
||||
(None, {'classes':('wide',), 'fields':('email', 'group', 'password1', 'password2')}),
|
||||
)
|
||||
|
||||
class JpnSubPerfAdmin(LeafletGeoAdmin):
|
||||
search_fields = ('adm0_ja', 'adm1_ja', 'adm2_ja', 'name_modified', 'area_name',)
|
||||
list_filter = ('adm0_ja', 'adm0_ja', 'name_modified',)
|
||||
ordering = ('adm0_ja',)
|
||||
list_display = ('adm0_ja','adm1_ja','adm2_ja' ,'name_modified', 'area_name',)
|
||||
|
||||
class LocationAdmin(LeafletGeoAdmin):
|
||||
search_fields = ('location_id', 'cp', 'location_name', 'category', 'event_name','group',)
|
||||
list_filter = ('event_name', 'group',)
|
||||
ordering = ('location_id', 'cp',)
|
||||
list_display = ('location_id','cp', 'location_name', 'category', 'group', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',)
|
||||
list_display = ('location_id','sub_loc_id', 'cp', 'location_name', 'category', 'group', 'event_name', 'event_active', 'auto_checkin', 'checkin_radius', 'checkin_point', 'buy_point',)
|
||||
|
||||
|
||||
def tranfer_to_location(modeladmin, request, queryset):
|
||||
@ -159,7 +165,7 @@ admin.site.register(JpnAdminMainPerf, LeafletGeoAdmin)
|
||||
admin.site.register(UserTracks, LeafletGeoAdmin);
|
||||
#admin.site.register(JpnAdminPerf, LeafletGeoAdmin)
|
||||
admin.site.register(GifuAreas, LeafletGeoAdmin)
|
||||
admin.site.register(JpnSubPerf, LeafletGeoAdmin)
|
||||
admin.site.register(JpnSubPerf, JpnSubPerfAdmin)
|
||||
admin.site.register(ShapeLayers, admin.ModelAdmin)
|
||||
admin.site.register(UserUpload, admin.ModelAdmin)
|
||||
admin.site.register(EventUser, admin.ModelAdmin)
|
||||
|
||||
@ -616,18 +616,18 @@ def publish_data(sender, instance, created, **kwargs):
|
||||
os.remove(file)
|
||||
|
||||
try:
|
||||
print("before reading the file")
|
||||
# print("before reading the file")
|
||||
shp = glob.glob(r'{}/**/*.shp'.format(file_path), recursive=True)[0]
|
||||
print("this is the read file",shp)
|
||||
# print("this is the read file",shp)
|
||||
gdf = gpd.read_file(shp)
|
||||
crs_name = str(gdf.crs.srs)
|
||||
print(crs_name, 'crs - name')
|
||||
# print(crs_name, 'crs - name')
|
||||
epsg = int(crs_name.replace('epsg:',''))
|
||||
if epsg is None:
|
||||
epsg=4326
|
||||
|
||||
lm2 = getTempMappingforModel(instance.layerof, shp)
|
||||
print("### shape file is ###")
|
||||
# print("### shape file is ###")
|
||||
lm2.save(strict=True, verbose=True)
|
||||
|
||||
os.remove(shp)
|
||||
@ -640,8 +640,8 @@ def publish_data(sender, instance, created, **kwargs):
|
||||
remove_bom_inplace(csv_f)
|
||||
|
||||
mdl = apps.get_model(app_label="rog", model_name=LAYER_CHOICES[instance.layerof -1][1])
|
||||
print(mdl)
|
||||
print(f"#### instance.layerof - {instance.layerof}")
|
||||
# print(mdl)
|
||||
# print(f"#### instance.layerof - {instance.layerof}")
|
||||
with open(csv_f, mode="r", encoding="utf-8") as txt_file:
|
||||
#heading = next(txt_file)
|
||||
reader = csv.reader(txt_file, delimiter=",")
|
||||
@ -686,11 +686,11 @@ def insertUserUploadUser(name, fields):
|
||||
def updateLocation(mdl, fields):
|
||||
print(f"Updating {fields[0]} - {fields[1]}")
|
||||
print(mdl.objects.filter(location_id = int(fields[0])))
|
||||
print("-------")
|
||||
print(f"--- ${fields} ----")
|
||||
|
||||
with transaction.atomic():
|
||||
mdl.objects.filter(location_id = int(fields[0])).update(
|
||||
sub_loc_id = fields[1] if len(fields[1]) > 0 else 0,
|
||||
sub_loc_id = fields[1] if len(fields[1]) > 0 else '',
|
||||
cp = fields[2] if len(fields[2]) > 0 else 0,
|
||||
location_name = fields[3] if len(fields[3]) > 0 else '',
|
||||
category = fields[4] if len(fields[4]) > 0 else '',
|
||||
|
||||
@ -68,7 +68,7 @@ class CreateUserSerializer(serializers.ModelSerializer):
|
||||
extra_kwargs = {'password': {'write_only': True}}
|
||||
|
||||
def create(self, validated_data):
|
||||
user = CustomUser.objects.create_user(validated_data['email'],validated_data['password'])
|
||||
user = CustomUser.objects.create_user(validated_data['email'],validated_data['password'], '大垣-初心者')
|
||||
return user
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
|
||||
@ -421,3 +421,4 @@ def CustomAreaNames(request):
|
||||
class TestActionViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = TestSerialiser
|
||||
queryset = TestModel.objects.all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user