| author | durandn |
| Mon, 05 Dec 2016 16:51:30 +0100 | |
| changeset 261 | 0d89d1066874 |
| parent 154 | 79b70254a5e0 |
| child 287 | 959cbaad2076 |
| permissions | -rw-r--r-- |
| 25 | 1 |
# How to start? |
2 |
||
3 |
1. Make sure PIP is installed then install Django and others dependencies with |
|
4 |
||
5 |
``` |
|
6 |
pip install -r requirements.txt |
|
7 |
||
8 |
``` |
|
9 |
||
|
44
6730ec4d7e37
fixing js dependencies
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
33
diff
changeset
|
10 |
2. Move to src/iconolab/static/js/iconolab-bundle to install js dependencies. |
| 25 | 11 |
Make sure your have installed nodejs then run the command bellow |
12 |
||
13 |
``` |
|
14 |
npm install |
|
15 |
||
16 |
``` |
|
17 |
3. To recreate the bundle file that lives in dist/ |
|
18 |
||
19 |
``` |
|
|
46
86608f92ebed
fixing tags
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents:
44
diff
changeset
|
20 |
npm run build |
| 25 | 21 |
|
22 |
``` |
|
23 |
||
24 |
4. To add a new js module, you can add it to the js/components folder and then run |
|
25 |
||
26 |
``` |
|
27 |
npm start |
|
28 |
``` |
|
29 |
||
30 |
## ICONOLAB ## |
|
31 |
||
32 |
### 1. Configuration and setup |
|
33 |
||
| 261 | 34 |
#### virtualenv |
| 25 | 35 |
|
36 |
- Install pip |
|
37 |
- Create a virtualenv for the project (using virtualenvwrapper is a good idea if possible). Python version is 3.5.1 |
|
38 |
- Run |
|
39 |
||
40 |
pip install -r requirements.txt |
|
41 |
||
42 |
||
| 261 | 43 |
#### node.js |
| 25 | 44 |
|
45 |
- Make sure nodejs is installed |
|
46 |
- cd into iconolab/src/iconolab/static/iconolab/js and run |
|
47 |
||
48 |
npm install |
|
49 |
||
50 |
- To recreate the bundle file that lives in dist/ |
|
51 |
||
52 |
npm build |
|
53 |
||
54 |
- To add a new js module, you can add it to the js/components folder and then run |
|
55 |
||
56 |
npm start |
|
57 |
||
| 261 | 58 |
#### Django project setup |
| 25 | 59 |
|
60 |
- Copy iconolab/src/settings/dev.py.tmpl into iconolab/src/settings/dev.py, adapt content to configuration |
|
61 |
- cd into iconolab/src folder and run |
|
62 |
||
63 |
python manage.py migrate |
|
64 |
||
65 |
to create database tables |
|
66 |
||
67 |
- Run |
|
68 |
||
69 |
python manage.py createsuperuser |
|
70 |
||
71 |
to create an admin user |
|
72 |
||
| 261 | 73 |
#### Elasticsearch |
| 25 | 74 |
|
| 261 | 75 |
Some objects in Iconolab are indexed and searched using ElasticSearch. You need to configure Haystack (see dev.py.tmpl, HAYSTACK_CONNECTIONS) and run: |
76 |
||
77 |
python manage.py rebuild_index |
|
| 25 | 78 |
|
79 |
||
80 |
### 2. Development server |
|
81 |
||
| 261 | 82 |
#### 2.1 Python server |
83 |
||
| 25 | 84 |
- cd into the iconolab/src folder and run |
85 |
||
86 |
python manage.py runserver |
|
87 |
||
88 |
By default, the app is accessible through http://127.0.0.1:8000/home |
|
89 |
||
| 261 | 90 |
#### 2.2 Javascript development |
91 |
||
92 |
- cd into the iconolab/src_js/iconolab-bundle folder and run |
|
93 |
||
94 |
npm install |
|
95 |
npm run start |
|
96 |
||
97 |
This will serve the iconolab.js file in the iconolab/src/iconolab/static/js and update it on changes you make in the js code in src_js so you can |
|
98 |
edit the code and debug it live in your browser |
|
99 |
||
100 |
### 3. Importing initial data from CSV |
|
| 25 | 101 |
|
| 140 | 102 |
Make sure to have the following in the same folder: |
| 25 | 103 |
|
| 140 | 104 |
* All the images to import. The image names must match their respective item inventory number. |
105 |
* A csv file that contains the metadata for the items you will import |
|
| 261 | 106 |
* A json file for initializing the collection in the database. (Optional if you want to import images in an existing collection) |
107 |
* A json file for the metacategories that will be linked to the collection. |
|
108 |
* Ensure the folder settings.MEDIA_ROOT+/uploads/ exists |
|
| 25 | 109 |
|
| 140 | 110 |
The following django manage.py command is used to import collection data and images: |
| 25 | 111 |
|
| 261 | 112 |
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> |
113 |
||
114 |
Options: |
|
115 |
--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) |
|
116 |
--encoding: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859 |
|
117 |
--collection-json: the json file to create the collection from |
|
118 |
--collection-id: the id of the collection to import into, it must already exist |
|
119 |
--metacategories-json: the json file to create metacategories on the collection we're importing into |
|
120 |
--jpeg-quality: the jpeg quality: default to the setting IMG_JPG_DEFAULT_QUALITY |
|
121 |
--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 |
|
122 |
--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". |
|
123 |
--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 .* |
|
124 |
--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 [\.\-_].* |
|
| 25 | 125 |
|
| 140 | 126 |
Notes: |
127 |
* The export csv path will be used to find everything else (images and fixtures files). |
|
128 |
* If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read |
|
| 261 | 129 |
* You MUST provide either --collection-json or --collection-id, else the command doesn't know to which collection the objects will belong to. |
130 |
* 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. |
|
131 |
* 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). |
|
132 |
||
133 |
### 4. Updating already existing data |
|
| 140 | 134 |
|
| 261 | 135 |
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. |
136 |
||
137 |
python manage.py updatecollection --collection-id=<:id> --delimiter=<:delimiter> --encoding=<:encoding> |
|
138 |
||
139 |
Options: |
|
140 |
--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) |
|
141 |
--encoding: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859 |
|
142 |
--collection-id: the id of the collection to import into, it must already exist |