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