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