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