README.md
author Riwad Salim
Tue, 05 Jun 2018 18:36:39 +0200
changeset 3 12fb6a535aa6
parent 1 309def3c05dc
child 18 a8b07497ae4b
permissions -rw-r--r--
Add specific templates to iconolab-mcc and edit docker settings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     1
## ICONOLAB-MCC 
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     2
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     3
### 1. Configuration and setup for development  
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     4
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     5
### virtualenv
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     6
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     7
- Install pip
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     8
- Create a virtualenv for the project (using virtualenvwrapper is a good idea if possible). Python version is 3.6.5
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
     9
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    10
Example
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    11
```
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    12
virtualenv -p python3.6 ./virtualenv
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    13
. virtualenv/bin/activate
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    14
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    15
cd src/
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    16
pip install -r requirements/dev.txt
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    17
```
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    18
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    19
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    20
### Django project setup
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    21
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    22
- Install iconolab
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    23
    pip install -e path/iconolab
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    24
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    25
- Copy iconolab/src/settings/dev.py.tmpl into iconolab-mcc/src/iconolab_mcc/settings/dev.py, adapt content to configuration
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    26
- cd into iconolab-mcc/src folder and run
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    27
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    28
    python manage.py migrate
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    29
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    30
to create database tables
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    31
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    32
- Run
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    33
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    34
    python manage.py createsuperuser
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    35
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    36
to create an admin user
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    37
3
12fb6a535aa6 Add specific templates to iconolab-mcc and edit docker settings
Riwad Salim
parents: 1
diff changeset
    38
1
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    39
- Collect static files
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    40
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    41
    python manage.py collectstatic
3
12fb6a535aa6 Add specific templates to iconolab-mcc and edit docker settings
Riwad Salim
parents: 1
diff changeset
    42
    
1
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    43
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    44
- Use Docker adress for HOST in settings
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    45
3
12fb6a535aa6 Add specific templates to iconolab-mcc and edit docker settings
Riwad Salim
parents: 1
diff changeset
    46
- don't use os.path.join(BASE_DIR, 'media') in settings
1
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    47
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    48
- make JS_DEV_MODE afalse (if not, it will not connect correctly on server)
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    49
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    50
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    51
### Iconolab to Iconolab-mcc
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    52
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    53
- Create uploads and cache repertories 
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    54
    MEDIA_ROOT/uploads and MEDIA_ROOT/cache
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    55
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    56
- Move the run directory into iconolab-mcc
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    57
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    58
- Create static directory
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    59
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    60
- Edit the settings in dev.py (using absolute path is better)
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    61
    BASE_DIR = '../iconolab-mcc/src/iconolab_mcc'
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    62
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    63
    STATIC_ROOT =  '../iconolab-mcc/run/web/static/site'
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    64
    MEDIA_ROOT = '../iconolab-mcc/run/web/media'
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    65
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    66
- Create templates and views directories
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    67
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    68
    iconolab-mcc/src/iconolab_mcc/templates
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    69
    iconolab-mcc/src/iconolab_mcc/views
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    70
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    71
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    72
- Add the charter, credits and legalmentions templates and it views and URLs (the URLs need to be on top)
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    73
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    74
    exemple for credits view in iconolab-mcc/src/iconolab_mcc/views/misc.py : 
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    75
    
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    76
    class CreditsView(TemplateView):
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    77
    template_name='iconolab_mcc/misc/credits.html'
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    78
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    79
    exemple for credits url in iconolab-mcc/src/urls.py  : 
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    80
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    81
    path('credits/', views.misc.CreditsView.as_view(), name="iconolab_mcc_credits"),
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    82
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    83
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    84
- Add line "from iconolab_mcc import" views in file iconolab_mcc/urls.py to access views
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    85
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    86
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    87
- Change "from iconolab.settings import *" into "from iconolab_mcc.settings import *" in the settings
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    88
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    89
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    90
- Add help and footer templates
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    91
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    92
    iconolab-mcc/src/iconolab_mcc/templates/misc/help.html
3
12fb6a535aa6 Add specific templates to iconolab-mcc and edit docker settings
Riwad Salim
parents: 1
diff changeset
    93
    iconolab-mcc/src/iconolab_mcc/templates/partials/footer.html
1
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    94
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    95
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    96
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    97
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    98
- Add logo_mcc_footer in src/iconolab_mcc/static/iconolab_mcc/img
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
    99
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   100
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   101
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   102
### Docker 
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   103
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   104
Migrate the file docker-compose.yml in iconolab-mcc project
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   105
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   106
- Create containers
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   107
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   108
    docker-compose up
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   109
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   110
- Run containers
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   111
    
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   112
    docker-compose start
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   113
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   114
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   115
### Elasticsearch
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   116
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   117
Some objects in Iconolab are indexed and searched using ElasticSearch. You need to configure Haystack (see dev.py.tmpl, HAYSTACK_CONNECTIONS) and run:
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   118
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   119
    python manage.py rebuild_index
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   120
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   121
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   122
### 2. Python server
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   123
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   124
- cd into the iconolab/src folder and run
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   125
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   126
    python manage.py runserver
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   127
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   128
By default, the app is accessible through http://127.0.0.1:8000/home
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   129
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   130
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   131
### 3. Importing initial data from CSV
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   132
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   133
Make sure to have the following in the same folder:
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   134
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   135
* All the images to import. The image names must match their respective item inventory number.
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   136
* A csv file that contains the metadata for the items you will import
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   137
* A json file for initializing the collection in the database. (Optional if you want to import images in an existing collection)
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   138
* A json file for the metacategories that will be linked to the collection.
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   139
* Ensure the folder settings.MEDIA_ROOT+/uploads/ exists
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   140
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   141
The following django manage.py command is used to import collection data and images:
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   142
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   143
```
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   144
python manage.py importimages <:export-csv-path> --delimiter <:delimiter> --encoding <:encoding> --collection-json <:collection_fixture_FILENAME> (OR --collection-id <:collection_id> if collection already exists in db) --metacategories-json <:metacategories_json_FILENAME>
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   145
```
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   146
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   147
Options:
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   148
- ```--delimiter```: the delimiter for the csv file. For special ascii characters add a # before the code. Supported special chars are 9 (tab), 29 (Group separator), 30 (Record separator), 31 (Unit separator)
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   149
- ```--encoding```: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   150
- ```--collection-json```: the json file to create the collection from
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   151
- ```--collection-id```: the id of the collection to import into, it must already exist
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   152
- ```--metacategories-json```: the json file to create metacategories on the collection we're importing into
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   153
- ```--jpeg-quality```: the jpeg quality: default to the setting IMG_JPG_DEFAULT_QUALITY
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   154
- ```--no-jpg-conversion```: set to True so the command will not convert the images to jpg. Useful for pre-converted jpeg and especially when importing large image banks
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   155
- ```--img-filename-identifier```: the column from which the command will try to find images in the folder: use keys from the setting IMPORT_FIELDS_DICT. Default is "INV".
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   156
- ```--filename-regexp-prefix```: allows you to customize the way the command try to find images by specifying a regexp pattern to match *before* the identifier provided in img-filename-identifier. Defaults to .*
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   157
- ```--filename-regexp-suffix```: allows you to customize the way the command try to find images by specifying a regexp pattern to match *after* the identifier provided in img-filename-identifier. Defaults to [\.\-_].*
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   158
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   159
Notes:
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   160
* The export csv path will be used to find everything else (images and fixtures files).
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   161
* If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   162
* You MUST provide either --collection-json or --collection-id, else the command doesn't know to which collection the objects will belong to.
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   163
* To find all images for a given item, the command will try to match filenames according to the pattern build from the 3 options: filename-regexp-prefix+<value of img-filename-identifier>+filename-regexp-suffix. For instance by default, for an object with an INV of MIC.3.10, the files MIC.3.10.jpg and MIC.3.10.verso.jpg would be matched and linked to the object.
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   164
* The command will first parse the csv, then create the objects in the database (Item and ItemMetadata), then move the images to the settings.MEDIA_ROOT+/uploads/ folder after converting them to JPEG, then create the database objects for the images. The command will ignore any csv row that lacks an image or any csv row that already has a database entry for the collection (by default INV number is used to test if a database entry exists).
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   165
    
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   166
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   167
### 4. Updating already existing data
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   168
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   169
Another management command allows for editing data using only a .csv file. The command will go through the csv and update the metadatas for every objects it finds in the database with the csv row content.
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   170
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   171
```
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   172
python manage.py updatecollection --collection-id=<:id> --delimiter=<:delimiter> --encoding=<:encoding>
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   173
```
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   174
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   175
Options:
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   176
- ```--delimiter```: the delimiter for the csv file. For special ascii characters add a # before the code. Supported special chars are 9 (tab), 29 (Group separator), 30 (Record separator), 31 (Unit separator)
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   177
- ```--encoding```: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   178
- ```--collection-id```: the id of the collection to import into, it must already exist
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   179
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   180
309def3c05dc Adding specific items to iconolab-mcc project interface
Riwad Salim
parents:
diff changeset
   181
 * document the test import command  : `python manage.py importimages --collection-json dossierImportMontauban/montauban_collection.json --metacategories-json dossierImportMontauban/montauban_metacategories_import.json --encoding "UTF-8" --delimiter "," dossierImportMontauban/ExportMontauban.csv`