README.md
changeset 1 3b0a8a6e685e
equal deleted inserted replaced
0:df27f9610c82 1:3b0a8a6e685e
       
     1 ## ICONOLAB-EPSITEME 
       
     2 
       
     3 ### 1. Configuration and setup for development  
       
     4 
       
     5 ### virtualenv
       
     6 
       
     7 - Install pip
       
     8 - Create a virtualenv for the project (using virtualenvwrapper is a good idea if possible). Python version is 3.6.5
       
     9 
       
    10 Example
       
    11 ```
       
    12 virtualenv -p python3.6 ./virtualenv
       
    13 . virtualenv/bin/activate
       
    14 
       
    15 cd src/
       
    16 pip install -r requirements/dev.txt
       
    17 ```
       
    18 
       
    19 
       
    20 ### Django project setup
       
    21 
       
    22 - Install iconolab
       
    23     pip install -e path/iconolab
       
    24 
       
    25 - Copy iconolab/src/settings/dev.py.tmpl into iconolab-episteme/src/iconolab_mcc/settings/dev.py, adapt content to configuration
       
    26 - cd into iconolab-episteme/src folder and run
       
    27 
       
    28     python manage.py migrate
       
    29 
       
    30 to create database tables
       
    31 
       
    32 - Run
       
    33 
       
    34     python manage.py createsuperuser
       
    35 
       
    36 to create an admin user
       
    37 
       
    38 
       
    39 - Collect static files
       
    40 
       
    41     python manage.py collectstatic
       
    42     
       
    43 
       
    44 - Use Docker adress for HOST in settings
       
    45 
       
    46 - don't use os.path.join(BASE_DIR, 'media') in settings
       
    47 
       
    48 - make JS_DEV_MODE afalse (if not, it will not connect correctly on server)
       
    49 
       
    50 
       
    51 ### Docker 
       
    52 
       
    53 Migrate the file docker-compose.yml in iconolab-episteme project
       
    54 
       
    55 - Create containers
       
    56 
       
    57     docker-compose up
       
    58 
       
    59 - Run containers
       
    60     
       
    61     docker-compose start
       
    62 
       
    63 
       
    64 ### Elasticsearch
       
    65 
       
    66 Some objects in Iconolab are indexed and searched using ElasticSearch. You need to configure the elasticsearch parameters (see dev.py.tmpl, ELASTICSEARCH_DSL) and run:
       
    67 
       
    68     python manage.py search_index --rebuild
       
    69 
       
    70 
       
    71 ### 2. Python server
       
    72 
       
    73 - cd into the iconolab-episteme/src folder and run
       
    74 
       
    75     python manage.py runserver
       
    76 
       
    77 By default, the app is accessible through http://127.0.0.1:8000/home
       
    78 
       
    79 
       
    80 ### 3. Importing initial data from CSV
       
    81 
       
    82 Make sure to have the following in the same folder:
       
    83 
       
    84 * All the images to import. The image names must match their respective item inventory number.
       
    85 * A csv file that contains the metadata for the items you will import
       
    86 * A json file for initializing the collection in the database. (Optional if you want to import images in an existing collection)
       
    87 * A json file for the metacategories that will be linked to the collection.
       
    88 * Ensure the folder settings.MEDIA_ROOT+/uploads/ exists
       
    89 
       
    90 The following django manage.py command is used to import collection data and images:
       
    91 
       
    92 ```
       
    93 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>
       
    94 ```
       
    95 
       
    96 Options:
       
    97 - ```--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)
       
    98 - ```--encoding```: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859
       
    99 - ```--collection-json```: the json file to create the collection from
       
   100 - ```--collection-id```: the id of the collection to import into, it must already exist
       
   101 - ```--metacategories-json```: the json file to create metacategories on the collection we're importing into
       
   102 - ```--jpeg-quality```: the jpeg quality: default to the setting IMG_JPG_DEFAULT_QUALITY
       
   103 - ```--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
       
   104 - ```--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".
       
   105 - ```--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 .*
       
   106 - ```--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 [\.\-_].*
       
   107 
       
   108 Notes:
       
   109 * The export csv path will be used to find everything else (images and fixtures files).
       
   110 * If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read
       
   111 * You MUST provide either --collection-json or --collection-id, else the command doesn't know to which collection the objects will belong to.
       
   112 * 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.
       
   113 * 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).
       
   114     
       
   115 
       
   116 ### 4. Updating already existing data
       
   117 
       
   118 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.
       
   119 
       
   120 ```
       
   121 python manage.py updatecollection --collection-id=<:id> --delimiter=<:delimiter> --encoding=<:encoding>
       
   122 ```
       
   123 
       
   124 Options:
       
   125 - ```--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)
       
   126 - ```--encoding```: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859
       
   127 - ```--collection-id```: the id of the collection to import into, it must already exist
       
   128 
       
   129 
       
   130  * 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`
       
   131 
       
   132 
       
   133 ### defining a new version
       
   134 
       
   135 To define a new version, the following steps must be taken.
       
   136 * if needed, refresh the `iconolab` version number in `src/setup.py`, in the key `install_requires`.
       
   137 * check that the matching tag has been published in the `iconolab` mercurial repository.
       
   138 * Update the version number in `src/iconolab_mcc/__init__.py`
       
   139 * Create a mercurial tag that matches the new version number
       
   140 * push the new commits and tag
       
   141