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