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