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