src/README.md
changeset 157 3abe2e799391
parent 154 79b70254a5e0
child 261 0d89d1066874
equal deleted inserted replaced
156:e1e14766f608 157:3abe2e799391
       
     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 
       
    10 2. Move to src/iconolab/static/js/iconolab-bundle to install js dependencies.
       
    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 ```
       
    20 npm run build
       
    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 
       
    34 ### virtualenv
       
    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 
       
    43 ### node.js
       
    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 
       
    58 ### Django project setup
       
    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 
       
    73 - Run
       
    74 
       
    75     python manage.py loaddata dev_initial_data
       
    76     
       
    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.
       
    78 
       
    79 
       
    80 ### 2. Development server
       
    81 
       
    82 - cd into the iconolab/src folder and run
       
    83 
       
    84 	python manage.py runserver
       
    85 	
       
    86 By default, the app is accessible through http://127.0.0.1:8000/home
       
    87 
       
    88 ### 3. Importing data from CSV
       
    89 
       
    90 Make sure to have the following in the same folder:
       
    91 
       
    92 * All the images to import. The image names must match their respective item inventory number.
       
    93 * A csv file that contains the metadata for the items you will import
       
    94 * A json fixture file for initializing the collection in the database. (Optional if you want to import images in an existing collection)
       
    95 * A json fixture file for the metacategories that will be linked to the collection.
       
    96 
       
    97 The following django manage.py command is used to import collection data and images:
       
    98 
       
    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> 
       
   100 	
       
   101 Notes: 
       
   102 * The export csv path will be used to find everything else (images and fixtures files). 
       
   103 * If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read
       
   104 * You MUST provide either --collection-fixture or --collection-id, else the command doesn't know to which collection the objects will belong to.
       
   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).
       
   106