README.md
author durandn
Thu, 18 Aug 2016 15:46:01 +0200
changeset 140 b0aae3bc25d2
parent 46 86608f92ebed
permissions -rw-r--r--
updated readme for importimages command
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     1
# How to start?
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     2
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     3
1. Make sure PIP is installed then install Django and others dependencies with 
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     4
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     5
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     6
pip install -r requirements.txt
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     7
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     8
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     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
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    11
Make sure your have installed nodejs then run the command bellow
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    12
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    13
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    14
npm install
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    15
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    16
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    17
3. To recreate the bundle file that lives in dist/
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    18
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    19
```
46
86608f92ebed fixing tags
Harris Baptiste <harris.baptiste@iri.centrepompidou.fr>
parents: 44
diff changeset
    20
npm run build
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    21
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    22
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    23
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    24
4. To add a new js module, you can add it to the js/components folder and then run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    26
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    27
npm start
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    28
```
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    29
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    30
## ICONOLAB ##
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    31
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    32
### 1. Configuration and setup
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    33
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    34
### virtualenv
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    35
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    36
- Install pip
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    37
- Create a virtualenv for the project (using virtualenvwrapper is a good idea if possible). Python version is 3.5.1
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    38
- Run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    39
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    40
	pip install -r requirements.txt
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    41
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    42
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    43
### node.js
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    44
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    45
- Make sure nodejs is installed
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    46
- cd into iconolab/src/iconolab/static/iconolab/js and run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    47
	
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    48
	npm install
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    49
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    50
- To recreate the bundle file that lives in dist/
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    51
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    52
	npm build
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    53
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    54
- To add a new js module, you can add it to the js/components folder and then run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    55
	
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    56
	npm start
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    57
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    58
### Django project setup
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    59
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    60
- Copy iconolab/src/settings/dev.py.tmpl into iconolab/src/settings/dev.py, adapt content to configuration
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    61
- cd into iconolab/src folder and run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    62
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    63
    python manage.py migrate
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    64
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    65
to create database tables
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    66
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    67
- Run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    68
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    69
    python manage.py createsuperuser
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    70
    
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    71
to create an admin user
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    72
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    73
- Run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    74
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    75
    python manage.py loaddata dev_initial_data
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    76
    
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    77
to load the provided data fixture. This fixture will create at least one of each object used in the app. Details on the fixture data below.
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    78
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    79
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    80
### 2. Development server
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    81
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    82
- cd into the iconolab/src folder and run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    83
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    84
	python manage.py runserver
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    85
	
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    86
By default, the app is accessible through http://127.0.0.1:8000/home
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    87
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    88
### 3. Importing data from CSV
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    89
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    90
Make sure to have the following in the same folder:
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    91
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    92
* All the images to import. The image names must match their respective item inventory number.
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    93
* A csv file that contains the metadata for the items you will import
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    94
* A json fixture file for initializing the collection in the database. (Optional if you want to import images in an existing collection)
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    95
* A json fixture file for the metacategories that will be linked to the collection.
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    96
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    97
The following django manage.py command is used to import collection data and images:
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    98
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    99
	python manage.py importimages <:export-csv-path> --encoding <:encoding> --collection-fixture <:collection_fixture_NAME> (OR --collection-id <:collection_id> --metacategories_fixture <:metacategories_fixture_NAME> 
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
   100
	
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   101
Notes: 
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   102
* The export csv path will be used to find everything else (images and fixtures files). 
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   103
* If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   104
* You MUST provide either --collection-fixture or --collection-id, else the command doesn't know to which collection the objects will belong to.
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   105
* 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 (INV number is used to test if a database entry exists).
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   106