REQUIRED: pip install geopy
[myslice.git] / README
1 This file documents the contents of this module
2 change
3 Last update 4 DEC. 2014
4
5 See the devel/ subdir for more devel-oriented doc.
6
7 ==================== 1 minute howto
8
9 *  REQUIREMENTS  is to have python + django (1.5.2) installed django
10 ** should be straightforward
11 ** see devel/django-install.txt in case of trouble
12 $ apt-get install python-django
13 $ apt-get install python-django-south
14 $ apt-get install python-pip or sudo easy_install pip==1.4.1
15 $ pip install requests
16 $ pip install djangorestframework
17 $ pip install django-celery
18 $ pip install geopy
19 * git clone git://git.onelab.eu/myslice.git
20 -- or --
21 * git clone ssh://yourlogin@git.onelab.eu/git/myslice.git
22
23 * edit/create myslice/myslice.ini and enter the details of your manifold backend
24
25 $ apt-get install python-django-south
26 * init django
27 ** when django prompts for creating an admin account, create it and 
28 ** keep the username and password safe
29 $ ./manage.py syncdb
30 $ ./manage.py migrate
31
32 * gather static files
33 $ ./manage.py collectstatic 
34 -- or --
35 $ ./manage.py collectstatic --noinput
36 -- or --
37 $ make static (which is a shorthand for cleaning up and run manage collectstatic --noinput)
38
39 * gather templates files 
40   for now we still seem to rely on a make-based templates-collection process
41   that creates templates/ 
42 $ make templates [$ make redo (each time when you pull, do that and restart the server)]
43
44
45 ## Whenever doing a git pull the following operations are recommended:
46
47 $ make static # will refresh static/ from all the pieces in the project
48 $ make templates # same, for templates
49 $ make redo-static # clears up (rm -rf) static/ first, then make static
50 $ make redo-templates # ditto for templates
51 $ make redo == make redo-static redo-templates
52
53
54 * run a local server:
55 $ ./manage.py runserver 0.0.0.0:8000
56 -- or -- my advice:
57 $ devel/server-loop.sh
58 when you just need to hit ^C yourself when your static files need to be refreshed - see below
59
60 * use it from your browser 
61 (See more notes on using the development server below)
62
63 * install dependencies 
64 $ pip install -r path/to/requirements/file.txt
65 Note. not quite sure what this is about, I could not spot this file..
66
67 =====APACHE Config=====
68 if are running apache please do:
69
70 $ chown www-data:www-data /var/myslice-f4f
71
72 otherwise you may get the following error:
73 "DatabaseError: unable to open database file"
74
75 ==================== Status
76
77 *** Authentication ***
78
79 Should be mostly fine
80 Not quite sure if/how the user gets proper notifications when
81 . his session has expired (i.e. his frontend is not logged into the backend any longer)
82 . his credentials have expired (i.e. the uploaded credentials, e.g. SFA delegated cred)
83   expired and she needs to run e.g. sfi myslice again
84
85 Hard-coded accounts (from a very early stage) are gone
86
87
88 *** Packaging ***
89
90 I've done a very rough attempt at packaging for rpm.
91 The logic seems about right but needs more work, in particular in terms of installing myslice.conf
92 in the httpd conf.d directory. 
93 It seems like our app won't work on f14 as is because Django is only 1.3.1 on f14
94 Plan is to target f18 but I lack a test machine.
95 Also of course I'll try to tackle debian/ubunti at some point.
96
97 There also is a working packaging for debian(s) and ubuntu(s) that we use 
98 on an almost daily basis to upgrade manifold.pl.sophia.inria.fr
99
100
101 ==================== 
102
103 Third party tools shipped:
104
105 * jquery
106 * datatables
107 * spin
108 * bootstrap
109
110 Others are added as we build the system when they become needed
111 Look in third-party/ for a more detailed list
112
113 As a rule of thumb, please try to keep in mind that these will need to
114 be upgraded over time I've tried to keep track of the version I picked
115 and to have an easy upgrade path (depending on the way the original
116 package is published)
117
118 ==================== Contents: 1st level subdirs
119
120 ========== code from git
121
122 * myslice/
123   this is the django 'project', where to look for
124   . settings.py
125   . urls.py
126
127 * manifold/
128   the code for dealing with queries, sending them to the backend, and offering the /manifold/proxy/ URL
129
130 * unfold/
131   the code for building / rendering plugins 
132
133 * plugins/
134   the actual code for plugins
135
136 * auth/ 
137   a django 'app' that deals with authentication; see especially
138   auth.backend.MyCustomBackend 
139   for how to use a separate authentication system, 
140   as well as settings.py for how to enable it
141
142 * ui/
143   provides building blocks for the UI, especially layouts (1 or 2 columns) as
144   well as the topmenu widget
145   + some global static files (css, js, images..)
146
147 * portal/
148   this is where the first implementation of myslice, with complete
149   user-management including registration, is taking place
150
151 * trash/
152   rough/preliminary scaffolding views are in here
153   as the name suggests this is temporary
154
155 * insert_above: 
156   a third-party django app for adding on-the-fly mentions to css or js files that need to go in the header
157
158 * third-party/
159    * third party javascript and css stuff (bootstrapfs, jquery, this kind of things)
160      see more about that below too
161
162 * devel:
163   no code in there, only various notes and other scripts useful for developers
164
165 ========== automatically generated 
166
167 * static/: (generated by collectstatic, see above, do not source-control)
168   $ manage.py [ --noinput ] collectstatic
169
170 * templates/
171
172 * myslice.sqlite3
173   this is where django stores its own stuff, as per settings.py
174
175 ==================== conventions for templates & static files
176 ==================== and NOTES on using the development server
177
178 . first off, running manage.py runserver is provided by django as a development convenience but
179   SHOULD NOT be used in production
180
181 . second, when you do use it for developement purposes, please be aware that:
182
183 .. the recommended layout for the various files and pieces (py, html, js and css) with django is e.g.
184       plugins/quickfilter/___init__.py, 
185       plugins/quickfilter/templates/quickfilter.html,
186       plugins/quickfilter/static/js/quickfilter.js 
187       plugins/quickfilter/static/css/quickfilter.css
188       plugins/quickfilter/static/img/some-image.png
189
190 .. the files actually used by the development server are the ones located in
191  static/
192  templates/
193
194 you can and should use the following make targets to refresh the
195 contents of these directories when running a developement server
196 $ make static                 to refresh static/
197 $ make redo-static            to clean up static/ and then refresh its contents
198 $ make templates              to refresh templates/
199 $ make redo-templates         to clean up templates/ and then refresh its contents
200 $ make redo                   equivalent to make redo-static redo-templates
201
202 .. as far as possible, please make sure to use third-party to store
203 any javascript tool or utility that your plugin depends upon
204
205 also we have the convention that all material in third-party should be
206 tagged with a version number, with a symlink pointing to the version
207 being used, like this
208
209 ~/git/myslice/third-party $ ls -ld spin*
210 lrwxr-xr-x  1 parmentelat  staff   10 Sep  6 17:55 spin -> spin-1.3.0
211 drwxr-xr-x  7 parmentelat  staff  238 Sep  6 17:55 spin-1.2.8
212 drwxr-xr-x  7 parmentelat  staff  238 Sep  6 17:55 spin-1.3.0
213
214 finally, as far as possible we keep track of the urls used to pull
215 stuff in the first place so that upgrades are easier
216
217 . third, be careful when importing third party material, to stay away from demo-oriented material
218
219 e.g. at some point we were using demo_page.css and demo_table.css from the datatables demo and sample pages
220 unfortunately these are not tailored for production use as they are setting styles on a very wide scope 
221 that breaks a lot of stuff, so please refrain from using these altogether
222
223
224 ======== update django database to reflect changes in existing models without any migration system (e.g., south) =========
225
226 # older version
227 $python manage.py reset <your_app>
228
229 #Django 1.5.1 or later
230 $python manage.py flush
231
232 This will update the database tables for your app, but will completely destroy any data that existed in those tables. 
233 If the changes you made to your app model do not break your old schema (for instance, you added a new, optional field) 
234 you can simply dump the data before and reload it afterwards, like so:
235
236 $python manage.py syncdb
237 $python manage.py dumpdata <your_app> > temp_data.json
238 $python manage.py flush
239 $python manage.py loaddata temp_data.json
240
241 If your changes break your old schema this won't work - in which case tools like south or django evolution are great.
242
243
244 Add a new model to the DB
245
246 $python manage.py schemamigration <your_app> --auto
247 $python manage.py migrate
248
249 ======== update django database to reflect changes in existing models with migration system (e.g., south) =========
250
251 As south is already installed , you just have to do:
252
253 # ./manage.py schemamigration portal --initial
254 # sqlite3 /var/unfold/unfold.sqlite3
255         sqlite> DROP TABLE "portal_institution";
256         sqlite> DROP TABLE "portal_pendinguser";
257         sqlite> DROP TABLE "portal_pendingauthority";
258         sqlite> DROP TABLE "portal_pendingslice";
259         sqlite> .quit
260 # ./manage.py migrate portal