INSTALLATION.html
23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Wiki</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style>
body { font:80% Verdana,Tahoma,Arial,sans-serif; }
h1, h2, h3, h4 { font-family: "Trebuchet MS",Georgia,"Times New Roman",serif; }
ul.toc { padding: 4px; margin-left: 0; }
ul.toc li { list-style-type:none; }
ul.toc li.heading2 { margin-left: 1em; }
ul.toc li.heading3 { margin-left: 2em; }
a.wiki-anchor { display: none; margin-left: 6px; text-decoration: none; }
a.wiki-anchor:hover { color: #aaa !important; text-decoration: none; }
h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display: inline; color: #ddd; }
</style>
</head>
<body>
<a name="Technical-Documentation-for-the-PYROS-project-FGFT-CC"></a>
<h1 >Technical Documentation for the PYROS project (FGFT-CC)<a href="#Technical-Documentation-for-the-PYROS-project-FGFT-CC" class="wiki-anchor">¶</a></h1>
<p>HOWTO Format Redmine Wiki : <a class="external" href="http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting">http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting</a></p>
<ul class="toc right"><li><a href="#Technical-Documentation-for-the-PYROS-project-FGFT-CC">Technical Documentation for the PYROS project (FGFT-CC)</a><ul><li><a href="#I-TODO">I - TODO</a></li><li><a href="#I-DATABASE-SCHEMA-v021">I - DATABASE SCHEMA (v0.2.1)</a></li><li><a href="#II-Get-the-project-from-gitlab">II - Get the project (from gitlab)</a><ul><li><a href="#Get-the-project-from-the-terminal">Get the project from the terminal</a></li><li><a href="#Get-the-project-from-Eclipse">Get the project from Eclipse</a></li></ul>
</li><li><a href="#III-INSTALLATION">III - INSTALLATION</a><ul><li><a href="#Install-MySql-only-if-necessary">Install MySql (only if necessary)</a></li><li><a href="#Install-Python35-only-if-necessary">Install Python3.5 (only if necessary)</a></li><li><a href="#Create-a-Python3-virtual-environment-dedicated-to-the-project-inside-the-project-folder">Create a Python3 virtual environment dedicated to the project (inside the project folder)</a></li><li><a href="#Activate-the-python-virtual-environment-from-inside-the-project">Activate the python virtual environment (from inside the project)</a></li><li><a href="#Install-the-needed-Python-packages-from-within-the-virtual-environment">Install the needed Python packages (from within the virtual environment)</a></li><li><a href="#Test-the-project">Test the project</a></li></ul>
</li><li><a href="#IV-CONFIGURATION-of-the-Django-Back-Office-administration-interface">IV - CONFIGURATION of the Django Back Office (administration interface)</a><ul><li><a href="#Back-Office-setup">Back Office setup</a></li><li><a href="#Adaptation-of-the-one-to-many-and-many-to-many-display">Adaptation of the one-to-many and many-to-many display</a></li></ul>
</li><li><a href="#V-INSTALLATION-FROM-THE-BEGINNING-for-dev-only-history-of-the-initial-project-creation">V - INSTALLATION FROM THE BEGINNING (for dev only, history of the initial project creation)</a></li></ul></li></ul>
<hr />
<a name="I-TODO"></a>
<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">I - TODO</span><a href="#I-TODO" class="wiki-anchor">¶</a></h2>
<ul>
<li>installation sur windows</li>
</ul>
<ul>
<li>gitlab</li>
</ul>
<ul>
<li>séparation des BD Django et Pyros</li>
</ul>
<ul>
<li>intégration dans Eclipse</li>
</ul>
<ul>
<li>Intégration des modules Django déjà développés</li>
</ul>
<hr />
<a name="I-DATABASE-SCHEMA-v021"></a>
<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">I - DATABASE SCHEMA (v0.2.1)</span><a href="#I-DATABASE-SCHEMA-v021" class="wiki-anchor">¶</a></h2>
<p><a href="/attachments/2510" class="thumbnail" title="Pyros data model"><img alt="PYROS_PDM_v021.png" src="/attachments/thumbnail/2510/300" /></a></p>
<hr />
<a name="II-Get-the-project-from-gitlab"></a>
<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">II - Get the project (from gitlab)</span><a href="#II-Get-the-project-from-gitlab" class="wiki-anchor">¶</a></h2>
<a name="Get-the-project-from-the-terminal"></a>
<h3 >Get the project from the terminal<a href="#Get-the-project-from-the-terminal" class="wiki-anchor">¶</a></h3>
<pre>
git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS
(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git)
</pre>
<p>This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)</p>
<p><em>If you just wanted a static copy of the project (without synchronization) just remove the .git/ folder:</em><br /><pre>
$ rm -r .git/
</pre></p>
<p>You should obtain this structure:</p>
<pre>
PYROS/
├── REQUIREMENTS.txt
├── private/
│ └── venv_py35_pyros/
├── public/
│ └── static/
├── src/
│ ├── manage.py
│ ├── pyros/
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ └── pyrosapp/
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── models.py
│ ├── tests.py
│ └── views.py
</pre>
<a name="Get-the-project-from-Eclipse"></a>
<h3 >Get the project from Eclipse<a href="#Get-the-project-from-Eclipse" class="wiki-anchor">¶</a></h3>
<pre>
TODO:
</pre>
<a name="III-INSTALLATION"></a>
<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">III - INSTALLATION</span><a href="#III-INSTALLATION" class="wiki-anchor">¶</a></h2>
<hr />
<a name="Install-MySql-only-if-necessary"></a>
<h3 >Install MySql (only if necessary)<a href="#Install-MySql-only-if-necessary" class="wiki-anchor">¶</a></h3>
<ul>
<li>Linux Ubuntu<br /><pre>
$ sudo apt-get install mysql-server
$ sudo apt-get install mysql-client
</pre></li>
</ul>
<ul>
<li>Linux CentOS<br /><pre>
TODO:
$ sudo yum install mysql
...
</pre></li>
</ul>
<ul>
<li>Mac OS X<br />Install XAMPP<br />(but you could also use the pre-installed Mac OS MySql)<br /><pre>
TODO:
</pre></li>
</ul>
<ul>
<li>Windows</li>
</ul>
<pre>
Download and install the newest version on https://dev.mysql.com/downloads/installer/
Once installed, launch MySQL Installer. Clic on 'Add...' on the right.
In MySQLServers section, choose the newest, then clic on next.
Install and configure the server (just follow the installation guide).
Then launch mysql (via the Windows menu).
</pre>
<hr />
<a name="Install-Python35-only-if-necessary"></a>
<h3 >Install Python3.5 (only if necessary)<a href="#Install-Python35-only-if-necessary" class="wiki-anchor">¶</a></h3>
<ul>
<li>Mac OS X :<br /><pre>
1) Installer MacPort
(TODO: doc)
2) Installer le "port" python35
$ sudo port install python35
</pre></li>
</ul>
<ul>
<li>Linux (Ubuntu) :<br /><pre>
$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.5
$ sudo pip install virtualenv
</pre></li>
</ul>
<ul>
<li>Windows 7 :<br /><pre>
Go to https://www.python.org/downloads/windows/ , choose the wanted version
On the wanted version’s page, download Windows x86 executable installer
Run the executable
* On the first page, check "Add python3.5 to PATH"
* Choose "Install now" option
Open cmd (windows + R, cmd) :
$ python -m pip install --upgrade pip
$ pip install virtualenv
</pre></li>
</ul>
<ul>
<li>Windows 10 :<br /><pre>
TODO:
</pre></li>
</ul>
<hr />
<a name="Create-a-Python3-virtual-environment-dedicated-to-the-project-inside-the-project-folder"></a>
<h3 >Create a Python3 virtual environment dedicated to the project (inside the project folder)<a href="#Create-a-Python3-virtual-environment-dedicated-to-the-project-inside-the-project-folder" class="wiki-anchor">¶</a></h3>
<pre>
$ mkdir private/
$ cd private/
$ which python3.5 ("where python" for windows)
/opt/local/bin/python3.5
$ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
=> creates a venv_py35_pyros/ folder inside PYROS/private/
</pre>
<hr />
<a name="Activate-the-python-virtual-environment-from-inside-the-project"></a>
<h3 >Activate the python virtual environment (from inside the project)<a href="#Activate-the-python-virtual-environment-from-inside-the-project" class="wiki-anchor">¶</a></h3>
<pre>
$ pwd
.../PYROS/private
$ source ./venv_py35_pyros/bin/activate (venv_py35_pyros/Scripts/activate on Windows)
$ python -V
Python 3.5.1
$ which pip
.../PYROS/venv_py35_pyros/bin/pip
Upgrade pip to last version available:
$ pip install --upgrade pip
Collecting pip
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
Installing collected packages: pip
Found existing installation: pip 7.1.2
Uninstalling pip-7.1.2:
Successfully uninstalled pip-7.1.2
Successfully installed pip-8.1.1
Upgrade wheel to last version available:
$ pip install --upgrade wheel
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Installing collected packages: wheel
Found existing installation: wheel 0.24.0
Uninstalling wheel-0.24.0:
Successfully uninstalled wheel-0.24.0
Successfully installed wheel-0.29.0
</pre>
<a name="Install-the-needed-Python-packages-from-within-the-virtual-environment"></a>
<h3 >Install the needed Python packages (from within the virtual environment)<a href="#Install-the-needed-Python-packages-from-within-the-virtual-environment" class="wiki-anchor">¶</a></h3>
<p>First, be sure that the virtual environment is activated:<br /><pre>
$ python -V
Python 3.5.1
</pre></p>
<ul>
<li><strong>Automatic Installation of all packages</strong><br /><pre>
$ pip install -r REQUIREMENTS.txt
</pre></li>
</ul>
<ul>
<li><strong>Or, manual installation of each package</strong>
<ul>
<li><strong>Install Django</strong> :<br /><pre>
$ pip install django
Collecting django
Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
Installing collected packages: django
Successfully installed django-1.9.4
$ pip install django-admin-tools
Collecting django-admin-tools
Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
Installing collected packages: django-admin-tools
Successfully installed django-admin-tools-0.7.2
$ pip install django-debug-toolbar
Collecting django-debug-toolbar
Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
Requirement already satisfied (use --upgrade to upgrade): Django>=1.7 in ./venv_py35_pyros/lib/python3.5/site-packages (from django-debug-toolbar)
Collecting sqlparse (from django-debug-toolbar)
Downloading sqlparse-0.1.19.tar.gz (58kB)
Building wheels for collected packages: sqlparse
Running setup.py bdist_wheel for sqlparse ... done
Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
Successfully built sqlparse
Installing collected packages: sqlparse, django-debug-toolbar
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
$ pip install django-extensions
Collecting django-extensions
Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
Collecting six>=1.2 (from django-extensions)
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, django-extensions
Successfully installed django-extensions-1.6.1 six-1.10.0
$ pip install django-suit
Collecting django-suit
Downloading django-suit-0.2.18.tar.gz (587kB)
Building wheels for collected packages: django-suit
Running setup.py bdist_wheel for django-suit ... done
Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
Successfully built django-suit
Installing collected packages: django-suit
Successfully installed django-suit-0.2.18
</pre></li>
</ul>
<ul>
<li><strong>Install the web application server gunicorn (will be used in production instead of the dev django web server)</strong> :<br /><pre>
$ pip install gunicorn
Collecting gunicorn
Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
Installing collected packages: gunicorn
Successfully installed gunicorn-19.4.5
</pre></li>
</ul>
<ul>
<li><strong>Install the python mysql client</strong>:<br /><pre>
$ pip install mysqlclient
...
</pre>
<ul>
<li>=> Issue under Mac OS X:<br /><pre>
$ pip install mysqlclient
Collecting mysqlclient
Downloading mysqlclient-1.3.7.tar.gz (79kB)
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
…
----------------------------------------
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.3.7
BOUH !!!
$ pip install --upgrade wheel
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
Installing collected packages: wheel
Found existing installation: wheel 0.24.0
Uninstalling wheel-0.24.0:
Successfully uninstalled wheel-0.24.0
Successfully installed wheel-0.29.0
$ pip uninstall mysqlclient
$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.7.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... done
Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.3.7
YES !!!
</pre></li>
</ul>
<ul>
<li>=> Issues under Ubuntu:<br /><pre>
$ pip install mysqlclient
Collecting mysqlclient
Downloading mysqlclient-1.3.7.tar.gz (79kB)
100% |████████████████████████████████| 81kB 1.5MB/s
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
[...]
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q6j4inuz/mysqlclient/
BOUH !!!
$ sudo apt-get install libmysqlclient-dev
$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.7.tar.gz
Building wheels for collected packages: mysqlclient
Running setup.py bdist_wheel for mysqlclient ... error
…
_mysql.c:40:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/carens_p/pyros/venv_py35_pyros/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-k3klv92j/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gz242xxs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/carens_p/pyros/venv_py35_pyros/include/site/python3.5/mysqlclient" failed with error code 1 in /tmp/pip-build-k3klv92j/mysqlclient/
BOUH !!!
$ sudo apt-get install python3.5-dev
$ pip install mysqlclient
YES !!!
</pre></li>
</ul></li>
</ul></li>
</ul>
<hr />
<a name="Test-the-project"></a>
<h3 >Test the project<a href="#Test-the-project" class="wiki-anchor">¶</a></h3>
<pre>
$ cd src/
$ ./manage.py runserver
(or gunicorn pyros.wsgi)
==> http://localhost:8000
...
...
Ctrl-c
</pre>
<hr />
<a name="IV-CONFIGURATION-of-the-Django-Back-Office-administration-interface"></a>
<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">IV - CONFIGURATION of the Django Back Office (administration interface)</span><a href="#IV-CONFIGURATION-of-the-Django-Back-Office-administration-interface" class="wiki-anchor">¶</a></h2>
<hr />
<a name="Back-Office-setup"></a>
<h3 >Back Office setup<a href="#Back-Office-setup" class="wiki-anchor">¶</a></h3>
<ul>
<li>Prerequisites in src/pyros/settings.py :
<ul>
<li>INSTALLED_APPS must (at least) contain :
<ul>
<li>django.contrib.admin</li>
<li>django.contrib.auth</li>
<li>django.contrib.contenttypes</li>
<li>django.contrib.sessions</li>
</ul></li>
</ul>
<ul>
<li>MIDDLEWARES must (at least) contain :
<ul>
<li>django.contrib.sessions.middleware.SessionMiddleware</li>
<li>django.middleware.common.CommonMiddleware</li>
<li>django.contrib.auth.middleware.AuthenticationMiddleware</li>
</ul></li>
</ul></li>
</ul>
<ul>
<li>At least one 'python manage.py migrate' must have been executed</li>
</ul>
<ul>
<li>Create a superuser for the administration :</li>
</ul>
<pre>
$ python manage.py createsuperuser
</pre>
<ul>
<li>For each app of the project, fill the admin.py file :</li>
</ul>
<pre>
from django.contrib import admin
from app.models import Model1, Model2
admin.site.register(Model1)
admin.site.register(Model2)
</pre>
<p><strong>Reminder</strong> : each application must be registered in the settings.py INSTALLED_APPS variable.</p>
<ul>
<li>For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example :</li>
</ul>
<pre>
class UserLevel(models.Model):
name = models.CharField(max_length=45, blank=True, null=True)
desc = models.TextField(blank=True, null=True)
priority = models.IntegerField(blank=True, null=True)
quota = models.FloatField(blank=True, null=True)
class Meta:
managed = True
db_table = 'userlevel'
def __str__(self):
return (str(self.name))
</pre>
<p><strong>Naming convention</strong> : Use self.name when possible, the creation time/date otherwise. Example :</p>
<pre>
class SiteWatch(models.Model):
updated = models.DateTimeField(blank=True, null=True)
lights = models.CharField(max_length=45, blank=True, null=True)
dome = models.CharField(max_length=45, blank=True, null=True)
doors = models.CharField(max_length=45, blank=True, null=True)
temperature = models.FloatField(blank=True, null=True)
class Meta:
managed = True
db_table = 'sitewatch'
def __str__(self):
return (str(self.updated))
</pre>
<hr />
<a name="Adaptation-of-the-one-to-many-and-many-to-many-display"></a>
<h3 >Adaptation of the one-to-many and many-to-many display<a href="#Adaptation-of-the-one-to-many-and-many-to-many-display" class="wiki-anchor">¶</a></h3>
<ul>
<li>The one-to-many relationships are the following (One.many format) :
<ul>
<li>Schedule.sequences</li>
<li>Request.sequences</li>
<li>Sequence.albums</li>
<li>Album.plans</li>
<li>Plan.images</li>
<li>Telescope.detectors</li>
<li>Detector.filters</li>
<li>NrtAnalysis.images</li>
<li>Filter.plans</li>
<li>Detector.albums</li>
<li>UserLevel.users</li>
<li>Country.users</li>
<li>ScientificProgram.requests</li>
<li>User.requests</li>
<li>StrategyObs.alerts</li>
<li>SequenceType.sequences</li>
</ul></li>
</ul>
<ul>
<li>For each "many", create a new class in admin.py just after the imports, following these examples :</li>
</ul>
<pre>
For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need :
class SequenceInline(admin.TabularInline):
model = Sequence
fields = ("name",)
show_change_link = True
For Sequence.albums and Detector.albums, we will need :
class AlbumInline(admin.TabularInline):
model = Album
fields = ("name",)
show_change_link = True
For StrategyObs.alerts, we will need :
class AlertInline(admin.TabularInline):
model = Alert
fields = ("request.name",) # there is no 'name' attribute in the Alert model
show_change_link = True
</pre>
<ul>
<li>For each "One", declare a new class in admin.py, just after the "Inlines" class declaration, as done in the following examples :</li>
</ul>
<pre>
For Request.sequences :
class RequestAdmin(admin.ModelAdmin):
inlines = [
SequenceInline,
]
For Detector.filters and Detector.albums :
class DetectorAdmin(admin.ModelAdmin):
inlines = [
FilterInline,
AlbumInline,
]
</pre>
<ul>
<li>The many-to-many relationships are the following :
<ul>
<li>ScientificProgram - User</li>
<li>ScheduleHistory - Sequence</li>
</ul></li>
</ul>
<ul>
<li>For each many-to-many relationship, declare a new "Inline" class in admin.py just after the imports, like this :</li>
</ul>
<pre>
For ScientificProgram - User :
class UserAndSPInline(admin.TabularInline):
model = ScientificProgram.users.through
For ScheduleHistory - Sequence
class SequenceAndSHInline(admin.TabularInline):
model = ScheduleHistory.sequences.through
</pre>
<p><ins>Note :</ins> The order in the line "model = ScientificProgram.users.through" is very important : the first model (ScientificProgram) is the one in which is declared the ManyToManyField relationship.</p>
<ul>
<li>For each many-to-many relationship, declare two new classes in admin.py, just after the inlines, like in the following examples :</li>
</ul>
<pre>
For the ScheduleHistory - Sequence relationship :
class ScheduleHistoryAdmin(admin.ModelAdmin):
inlines = [
SequenceAndSHInline,
]
exclude = ('sequences',) # ScheduleHistory declares the ManyToManyField, and we want to replace its display in the back office, so we won't display the default field
class SequenceAdmin(admin.ModelAdmin):
inlines = [
AlbumInline, # This is the Inline for the one-to-many relationship Sequence.albums
SequenceAndSHInline,
]
For the ScientificProgram - User relationship :
class ScientificProgramAdmin(admin.ModelAdmin):
inlines = [
RequestInline,
UserAndSPInline,
]
exclude = ('users',) # Same as ScheduleHistory
class UserAdmin(admin.ModelAdmin):
inlines = [
RequestInline, # This is the Inline for the one-to-many relationship User.requests
UserAndSPInline,
]
</pre>
<ul>
<li>For each ModelAdmin class in the admin.py, change the registering line</li>
</ul>
<pre>
admin.site.register(Album)
</pre>
<p>to</p>
<pre>
admin.site.register(Album, AlbumAdmin)
</pre>
<a name="V-INSTALLATION-FROM-THE-BEGINNING-for-dev-only-history-of-the-initial-project-creation"></a>
<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">V - INSTALLATION FROM THE BEGINNING (for dev only, history of the initial project creation)</span><a href="#V-INSTALLATION-FROM-THE-BEGINNING-for-dev-only-history-of-the-initial-project-creation" class="wiki-anchor">¶</a></h2>
<p><a href="Pyros_install_from_start.html" class="wiki-page">Pyros installation from the beginning</a></p>
</body>
</html>