split feature model – beginnings (still missing: API, Forms, Editor)
This commit is contained in:
parent
55a7e20df1
commit
0036b27057
15 changed files with 238 additions and 156 deletions
|
@ -1,3 +1,4 @@
|
|||
from c3nav.mapdata.models import Feature, Level, Package, Source
|
||||
from c3nav.mapdata.models import Level, Package, Source
|
||||
from c3nav.mapdata.models.features import Inside, Room
|
||||
|
||||
ordered_models = (Package, Level, Source, Feature)
|
||||
ordered_models = (Package, Level, Source, Inside, Room)
|
||||
|
|
|
@ -2,6 +2,7 @@ import json
|
|||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management import CommandError
|
||||
|
@ -15,6 +16,8 @@ class MapdataReader:
|
|||
self.content = {}
|
||||
self.package_names_by_dir = {}
|
||||
self.saved_items = {model: {} for model in ordered_models}
|
||||
self.path_regexes = OrderedDict((model, model.get_path_regex()) for model in ordered_models)
|
||||
print(self.path_regexes)
|
||||
|
||||
def read_packages(self):
|
||||
print('Detecting Map Packages…')
|
||||
|
@ -44,8 +47,8 @@ class MapdataReader:
|
|||
file_path = os.path.join(package_dir, path, filename)
|
||||
relative_file_path = os.path.join(path, filename)
|
||||
print(file_path)
|
||||
for model in ordered_models:
|
||||
if re.search(model.path_regex, relative_file_path):
|
||||
for model, path_regex in self.path_regexes.items():
|
||||
if re.search(path_regex, relative_file_path):
|
||||
self._add_item(ReaderItem(self, package_dir, path, filename, model))
|
||||
break
|
||||
else:
|
||||
|
|
|
@ -24,7 +24,7 @@ class MapdataWriter:
|
|||
count = 0
|
||||
for model in ordered_models:
|
||||
for obj in model.objects.all().order_by('name').prefetch_related():
|
||||
file_path = os.path.join(obj.package.directory, obj.tofilename())
|
||||
file_path = os.path.join(obj.package.directory, obj.get_filename())
|
||||
full_file_path = os.path.join(settings.MAP_ROOT, file_path)
|
||||
self.keep.add(file_path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue