--- a/src/iconolab/management/commands/importimages.py Sun Jun 24 02:24:02 2018 +0200
+++ b/src/iconolab/management/commands/importimages.py Tue Jun 26 16:06:53 2018 +0200
@@ -22,7 +22,7 @@
metadata_dict,
image_files,
options,
- source_dir
+ source_dir,
):
target_dir = os.path.join(settings.MEDIA_ROOT, Image.media.field.upload_to)
@@ -47,9 +47,9 @@
print('##### Copying file '+str(image)+' without converting')
image_path = os.path.join(target_dir, image)
new_image_name = image
- shutil.copy(os.path.join(source_dir, image), target_dir)
+ shutil.copy(os.path.join(source_dir, image), image_path)
try:
- im = ImagePIL.open(os.path.join(target_dir, image))
+ im = ImagePIL.open(image_path)
im_width, im_height = im.size
except Exception as e:
print(e)
--- a/src/iconolab/models.py Sun Jun 24 02:24:02 2018 +0200
+++ b/src/iconolab/models.py Tue Jun 26 16:06:53 2018 +0200
@@ -134,6 +134,10 @@
"""
metadata = models.TextField(default="", null=False)
+ @staticmethod
+ def get_natural_key(collection, raw_natural_key):
+ return '%s|%s' % (collection.name, raw_natural_key)
+
def __init__(self, *args, **kwargs):
self.__metadata_obj = None
self.__raw_natural_key = None
--- a/src/iconolab/search_indexes/urls.py Sun Jun 24 02:24:02 2018 +0200
+++ b/src/iconolab/search_indexes/urls.py Tue Jun 26 16:06:53 2018 +0200
@@ -5,8 +5,8 @@
app_name = "iconolab-search_indexes"
urlpatterns = [
- url(r'collection/(?P<collection_name>[a-z0-9\-]+)/model/(?P<model_type>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="collection_with_model_search"),
- url(r'collection/(?P<collection_name>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="collection_search"),
+ url(r'collection/(?P<collection_name>[a-zA-Z0-9\-]+)/model/(?P<model_type>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="collection_with_model_search"),
+ url(r'collection/(?P<collection_name>[a-zA-Z0-9\-]+)', views.IconolabSearchView.as_view(), name="collection_search"),
url(r'^model/(?P<model_type>[a-z0-9\-]+)', views.IconolabSearchView.as_view(), name="model_search"),
url(r'^global/$', views.IconolabSearchView.as_view(), name="global_search"),
]