Commit 1a8abf18ba4f55b8a6a6226ca276b10a995eff36
1 parent
3cc75c0f
Exists in
master
and in
1 other branch
updated install doc
Showing
3 changed files
with
345 additions
and
512 deletions
Show diff stats
install/INSTALLATION.html
1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
2 | 2 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
3 | 3 | <head> |
4 | -<title>Wiki</title> | |
4 | +<title>Project Installation</title> | |
5 | 5 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
6 | 6 | <style> |
7 | 7 | body { font:80% Verdana,Tahoma,Arial,sans-serif; } |
... | ... | @@ -16,49 +16,20 @@ h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display |
16 | 16 | </style> |
17 | 17 | </head> |
18 | 18 | <body> |
19 | -<a name="Technical-Documentation-for-the-PYROS-project-FGFT-CC"></a> | |
20 | -<h1 >Technical Documentation for the PYROS project (FGFT-CC)<a href="#Technical-Documentation-for-the-PYROS-project-FGFT-CC" class="wiki-anchor">¶</a></h1> | |
19 | +<a name="Project-Installation"></a> | |
20 | +<h1 >Project Installation<a href="#Project-Installation" class="wiki-anchor">¶</a></h1> | |
21 | 21 | |
22 | 22 | |
23 | - <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> | |
24 | - | |
25 | - | |
26 | - <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> | |
27 | -</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> | |
28 | -</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> | |
29 | -</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> | |
30 | - | |
31 | - | |
32 | -<hr /> | |
33 | - | |
23 | + <p>Project Development page : <a href="Project_Development.html" class="wiki-page">Project Development</a></p> | |
34 | 24 | |
35 | - <a name="I-TODO"></a> | |
36 | -<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> | |
37 | 25 | |
38 | - | |
39 | - <ul> | |
40 | - <li>installation sur windows</li> | |
41 | - </ul> | |
42 | - | |
43 | - | |
44 | - <ul> | |
45 | - <li>gitlab</li> | |
46 | - </ul> | |
47 | - | |
48 | - | |
49 | - <ul> | |
50 | - <li>séparation des BD Django et Pyros</li> | |
51 | - </ul> | |
52 | - | |
53 | - | |
54 | - <ul> | |
55 | - <li>intégration dans Eclipse</li> | |
56 | - </ul> | |
26 | + <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> | |
57 | 27 | |
58 | 28 | |
59 | - <ul> | |
60 | - <li>Intégration des modules Django déjà développés</li> | |
61 | - </ul> | |
29 | + <ul class="toc right"><li><a href="#Project-Installation">Project Installation</a><ul><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="#Browse-the-code-from-gitlab">Browse the code from gitlab</a></li><li><a href="#Project-structure">Project structure</a></li><li><a href="#From-the-terminal">From the terminal</a></li><li><a href="#From-Eclipse">From Eclipse</a></li><li><a href="#For-easier-installation-you-can-use-Sqlite-instead-of-Mysql">For easier installation, you can use Sqlite instead of Mysql</a></li></ul> | |
30 | +</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="#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter">(Eclipse only) Set the Python3 virtual environment as the project interpreter</a></li><li><a href="#Run-the-project">Run the project</a><ul><li><a href="#From-the-terminal-2">From the terminal</a></li><li><a href="#From-Eclipse-2">From Eclipse</a></li></ul> | |
31 | +</li></ul> | |
32 | +</li><li><a href="#IV-TEST">IV - TEST</a><ul><li><a href="#From-Terminal">From Terminal</a></li><li><a href="#From-Eclipse-3">From Eclipse:</a></li><li><a href="#Custom-commands-">Custom commands :</a></li></ul></li></ul></li></ul> | |
62 | 33 | |
63 | 34 | |
64 | 35 | <hr /> |
... | ... | @@ -68,7 +39,7 @@ h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display |
68 | 39 | <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> |
69 | 40 | |
70 | 41 | |
71 | - <p><a href="/attachments/2510" class="thumbnail" title="Pyros data model"><img alt="PYROS_PDM_v021.png" src="/attachments/thumbnail/2510/300" /></a></p> | |
42 | + <p><a href="/attachments/2543" class="thumbnail" title="Pyros data model"><img alt="PYROS_PDM_v021.png" src="/attachments/thumbnail/2543/300" /></a></p> | |
72 | 43 | |
73 | 44 | |
74 | 45 | <hr /> |
... | ... | @@ -78,33 +49,26 @@ h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display |
78 | 49 | <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> |
79 | 50 | |
80 | 51 | |
81 | - <a name="Get-the-project-from-the-terminal"></a> | |
82 | -<h3 >Get the project from the terminal<a href="#Get-the-project-from-the-terminal" class="wiki-anchor">¶</a></h3> | |
52 | + <a name="Browse-the-code-from-gitlab"></a> | |
53 | +<h3 >Browse the code from gitlab<a href="#Browse-the-code-from-gitlab" class="wiki-anchor">¶</a></h3> | |
83 | 54 | |
84 | 55 | |
85 | -<pre> | |
86 | -git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS | |
87 | - | |
88 | -(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git) | |
89 | -</pre> | |
90 | - | |
91 | - <p>This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)</p> | |
56 | + <p><a class="external" href="https://gitlab.irap.omp.eu/epallier/pyros/tree/master">https://gitlab.irap.omp.eu/epallier/pyros/tree/master</a></p> | |
92 | 57 | |
93 | 58 | |
94 | - <p><em>If you just wanted a static copy of the project (without synchronization) just remove the .git/ folder:</em><br /><pre> | |
95 | -$ rm -r .git/ | |
96 | -</pre></p> | |
59 | + <a name="Project-structure"></a> | |
60 | +<h3 >Project structure<a href="#Project-structure" class="wiki-anchor">¶</a></h3> | |
97 | 61 | |
98 | 62 | |
99 | - <p>You should obtain this structure:</p> | |
63 | + <p>Once you have fetched the project, you should obtain this structure:</p> | |
100 | 64 | |
101 | 65 | |
102 | 66 | <pre> |
103 | 67 | |
104 | 68 | PYROS/ |
105 | -├── REQUIREMENTS.txt | |
106 | -├── private/ | |
107 | -│ └── venv_py35_pyros/ | |
69 | +├── install/ | |
70 | +│ └── REQUIREMENTS.txt | |
71 | +│ └── INSTALLATION.txt | |
108 | 72 | ├── public/ |
109 | 73 | │ └── static/ |
110 | 74 | ├── src/ |
... | ... | @@ -126,14 +90,109 @@ PYROS/ |
126 | 90 | |
127 | 91 | </pre> |
128 | 92 | |
129 | - <a name="Get-the-project-from-Eclipse"></a> | |
130 | -<h3 >Get the project from Eclipse<a href="#Get-the-project-from-Eclipse" class="wiki-anchor">¶</a></h3> | |
93 | + <a name="From-the-terminal"></a> | |
94 | +<h3 >From the terminal<a href="#From-the-terminal" class="wiki-anchor">¶</a></h3> | |
131 | 95 | |
132 | 96 | |
133 | 97 | <pre> |
134 | -TODO: | |
98 | +git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS | |
99 | +(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS) | |
135 | 100 | </pre> |
136 | 101 | |
102 | + <p>This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository)</p> | |
103 | + | |
104 | + | |
105 | + <p><em>If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:</em><br /><pre> | |
106 | +$ rm -r .git/ | |
107 | +</pre></p> | |
108 | + | |
109 | + | |
110 | + <a name="From-Eclipse"></a> | |
111 | +<h3 >From Eclipse<a href="#From-Eclipse" class="wiki-anchor">¶</a></h3> | |
112 | + | |
113 | + | |
114 | + <p>0) Install Eclipse (if necessary)</p> | |
115 | + | |
116 | + | |
117 | + <p>Get the Eclipse version for Php</p> | |
118 | + | |
119 | + | |
120 | + <p>Install the plug-in pydev (via install new software, add <a class="external" href="http://pydev.org/updates">http://pydev.org/updates</a>)</p> | |
121 | + | |
122 | + | |
123 | + <p>1) Deactivate CA certificate verification</p> | |
124 | + | |
125 | + | |
126 | + <p>Window -> Preferences -> Team -> git -> configuration -> Add entry</p> | |
127 | + | |
128 | + | |
129 | + <p>Key = http.sslVerify<br />Value = false</p> | |
130 | + | |
131 | + | |
132 | + <p>2) Fetch the project</p> | |
133 | + | |
134 | + | |
135 | + <p>File/Import project from git</p> | |
136 | + | |
137 | + | |
138 | + <p>Select repository source: Clone URI: <a class="external" href="https://gitlab.irap.omp.eu/epallier/pyros.git">https://gitlab.irap.omp.eu/epallier/pyros.git</a></p> | |
139 | + | |
140 | + | |
141 | + <p>Directory: <br />par défaut, il propose : /Users/epallier/git/pyros<br />mais on peut le mettre ailleurs (c'est ce que j'ai fait)</p> | |
142 | + | |
143 | + | |
144 | + <p>initial branch: master<br />remote name: origin</p> | |
145 | + | |
146 | + | |
147 | + <p>Import as general project</p> | |
148 | + | |
149 | + | |
150 | + <p>Project name: PYROS</p> | |
151 | + | |
152 | + | |
153 | + <p>3) Configure the project</p> | |
154 | + | |
155 | + | |
156 | + <p>The project is created. Now, you have to set it as a «PyDev » and a « Django » project.</p> | |
157 | + | |
158 | + | |
159 | + <p>clic droit sur le projet / PyDev / set as a PyDev project</p> | |
160 | + | |
161 | + | |
162 | + <p>clic droit sur le projet / PyDev / set as a Django project</p> | |
163 | + | |
164 | + | |
165 | + <p>clic droit sur le projet : on doit maintenant avoir un sous-menu Django</p> | |
166 | + | |
167 | + | |
168 | + <p>clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH)</p> | |
169 | + | |
170 | + | |
171 | + <p>clic droit sur projet / Properties / Pydev-Django :<br /> - Django manage.py : src/manage.py<br /> - Django settings module : pyros.settings</p> | |
172 | + | |
173 | + | |
174 | + <p>4) Set Code style</p> | |
175 | + | |
176 | + | |
177 | + <p>Window/Preferences : Pydev / Editor<br />- Auto Imports : uncheck « Do auto import »<br />- Code style:<br /> - Locals … : camelCase<br /> - Methods : camelCase() with first lower<br />- Code style / Code Formatter: activer « use autopep8.py for code formatting »<br />- Tabs : Tab length : 4</p> | |
178 | + | |
179 | + | |
180 | + <p>(<br />il faudra aussi faire un peu plus loin : <br /><a class="external" href="https://projects.irap.omp.eu/projects/pyros/wiki/Project_Installation#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter">https://projects.irap.omp.eu/projects/pyros/wiki/Project_Installation#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter</a><br />)</p> | |
181 | + | |
182 | + | |
183 | + <a name="For-easier-installation-you-can-use-Sqlite-instead-of-Mysql"></a> | |
184 | +<h3 >For easier installation, you can use Sqlite instead of Mysql<a href="#For-easier-installation-you-can-use-Sqlite-instead-of-Mysql" class="wiki-anchor">¶</a></h3> | |
185 | + | |
186 | + | |
187 | + <p>By default, Mysql will be used, but then you will need to install the Mysql database server.</p> | |
188 | + | |
189 | + | |
190 | + <p>Thus, in order to skip Mysql installation, use Sqlite instead as the database server (which will need no installation at all) :</p> | |
191 | + | |
192 | + | |
193 | + <p>Edit pyros/settings.py and just set MYSQL variable to False, and that's it.</p> | |
194 | + | |
195 | + | |
137 | 196 | <a name="III-INSTALLATION"></a> |
138 | 197 | <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> |
139 | 198 | |
... | ... | @@ -145,6 +204,8 @@ TODO: |
145 | 204 | <h3 >Install MySql (only if necessary)<a href="#Install-MySql-only-if-necessary" class="wiki-anchor">¶</a></h3> |
146 | 205 | |
147 | 206 | |
207 | + <p><strong>Skip this step if you are using Sqlite instead of MySql</strong> | |
208 | + | |
148 | 209 | <ul> |
149 | 210 | <li>Linux Ubuntu<br /><pre> |
150 | 211 | |
... | ... | @@ -174,6 +235,7 @@ TODO: |
174 | 235 | <ul> |
175 | 236 | <li>Windows</li> |
176 | 237 | </ul> |
238 | +</p> | |
177 | 239 | |
178 | 240 | |
179 | 241 | <pre> |
... | ... | @@ -303,6 +365,9 @@ Successfully installed wheel-0.29.0 |
303 | 365 | |
304 | 366 | </pre> |
305 | 367 | |
368 | +<hr /> | |
369 | + | |
370 | + | |
306 | 371 | <a name="Install-the-needed-Python-packages-from-within-the-virtual-environment"></a> |
307 | 372 | <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> |
308 | 373 | |
... | ... | @@ -439,7 +504,6 @@ YES !!! |
439 | 504 | $ pip install mysqlclient |
440 | 505 | Collecting mysqlclient |
441 | 506 | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
442 | - 100% |████████████████████████████████| 81kB 1.5MB/s | |
443 | 507 | Complete output from command python setup.py egg_info: |
444 | 508 | /bin/sh: 1: mysql_config: not found |
445 | 509 | Traceback (most recent call last): |
... | ... | @@ -481,308 +545,147 @@ YES !!! |
481 | 545 | </ul> |
482 | 546 | |
483 | 547 | |
484 | -<hr /> | |
485 | - | |
486 | - | |
487 | - <a name="Test-the-project"></a> | |
488 | -<h3 >Test the project<a href="#Test-the-project" class="wiki-anchor">¶</a></h3> | |
489 | - | |
548 | + <ul> | |
549 | + <li>=> Issue under Windows<br /><pre> | |
550 | +Same message as the issue for Mac. | |
490 | 551 | |
491 | -<pre> | |
552 | +Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel | |
492 | 553 | |
493 | -$ cd src/ | |
554 | +$ pip install path\to\mysqlclient\wheel | |
494 | 555 | |
495 | -$ ./manage.py runserver | |
496 | -(or gunicorn pyros.wsgi) | |
497 | -==> http://localhost:8000 | |
498 | -... | |
499 | -... | |
500 | -Ctrl-c | |
556 | +No need to redo "pip install mysqlclient" | |
557 | +</pre></li> | |
558 | + </ul> | |
501 | 559 | |
502 | -</pre> | |
503 | 560 | |
504 | 561 | <hr /> |
505 | 562 | |
506 | 563 | |
507 | - <a name="IV-CONFIGURATION-of-the-Django-Back-Office-administration-interface"></a> | |
508 | -<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> | |
509 | - | |
510 | - | |
511 | -<hr /> | |
564 | + <a name="Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter"></a> | |
565 | +<h3 >(Eclipse only) Set the Python3 virtual environment as the project interpreter<a href="#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter" class="wiki-anchor">¶</a></h3> | |
512 | 566 | |
513 | 567 | |
514 | - <a name="Back-Office-setup"></a> | |
515 | -<h3 >Back Office setup<a href="#Back-Office-setup" class="wiki-anchor">¶</a></h3> | |
568 | + <p>clic droit sur projet / Properties / PyDev - Interpreter/Grammar :<br />Grammar version : 3</p> | |
516 | 569 | |
517 | 570 | |
518 | - <ul> | |
519 | - <li>Prerequisites in src/pyros/settings.py : | |
571 | + <p>Interpreter : click on « click here to configure an interpreter not listed »</p> | |
520 | 572 | |
521 | - <ul> | |
522 | - <li>INSTALLED_APPS must (at least) contain : | |
523 | 573 | |
524 | - <ul> | |
525 | - <li>django.contrib.admin</li> | |
526 | - <li>django.contrib.auth</li> | |
527 | - <li>django.contrib.contenttypes</li> | |
528 | - <li>django.contrib.sessions</li> | |
529 | - </ul></li> | |
530 | - </ul> | |
574 | + <p>click on « New » :<br />- Interpreter name : venv_py35_pyros<br />- Interpreter executable : click on « Browse »<br /> Select your private/venv_py35_pyros/bin/python3.5 executable<br /> click OK<br /> click OK again</p> | |
531 | 575 | |
532 | 576 | |
533 | - <ul> | |
534 | - <li>MIDDLEWARES must (at least) contain : | |
577 | + <p>Interpreter: select now venv_py35_pyros from the list</p> | |
535 | 578 | |
536 | - <ul> | |
537 | - <li>django.contrib.sessions.middleware.SessionMiddleware</li> | |
538 | - <li>django.middleware.common.CommonMiddleware</li> | |
539 | - <li>django.contrib.auth.middleware.AuthenticationMiddleware</li> | |
540 | - </ul></li> | |
541 | - </ul></li> | |
542 | - </ul> | |
543 | 579 | |
580 | +<hr /> | |
544 | 581 | |
545 | - <ul> | |
546 | - <li>At least one 'python manage.py migrate' must have been executed</li> | |
547 | - </ul> | |
548 | 582 | |
583 | + <a name="Run-the-project"></a> | |
584 | +<h3 >Run the project<a href="#Run-the-project" class="wiki-anchor">¶</a></h3> | |
549 | 585 | |
550 | - <ul> | |
551 | - <li>Create a superuser for the administration :</li> | |
552 | - </ul> | |
553 | 586 | |
587 | + <p>TODO: more details... (notamment sur localhost:8000/admin)</p> | |
554 | 588 | |
555 | -<pre> | |
556 | -$ python manage.py createsuperuser | |
557 | -</pre> | |
558 | 589 | |
559 | - <ul> | |
560 | - <li>For each app of the project, fill the admin.py file :</li> | |
561 | - </ul> | |
590 | + <a name="From-the-terminal-2"></a> | |
591 | +<h4 >From the terminal<a href="#From-the-terminal-2" class="wiki-anchor">¶</a></h4> | |
562 | 592 | |
563 | 593 | |
564 | 594 | <pre> |
565 | -from django.contrib import admin | |
566 | -from app.models import Model1, Model2 | |
567 | - | |
568 | -admin.site.register(Model1) | |
569 | -admin.site.register(Model2) | |
570 | -</pre> | |
571 | 595 | |
572 | - <p><strong>Reminder</strong> : each application must be registered in the settings.py INSTALLED_APPS variable.</p> | |
573 | - | |
574 | - | |
575 | - <ul> | |
576 | - <li>For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example :</li> | |
577 | - </ul> | |
596 | +$ cd src/ | |
578 | 597 | |
598 | +$ ./manage.py runserver | |
599 | +(or gunicorn pyros.wsgi) | |
600 | +==> http://localhost:8000 | |
601 | +... | |
602 | +... | |
603 | +Ctrl-c | |
579 | 604 | |
580 | -<pre> | |
581 | -class UserLevel(models.Model): | |
582 | - name = models.CharField(max_length=45, blank=True, null=True) | |
583 | - desc = models.TextField(blank=True, null=True) | |
584 | - priority = models.IntegerField(blank=True, null=True) | |
585 | - quota = models.FloatField(blank=True, null=True) | |
586 | - | |
587 | - class Meta: | |
588 | - managed = True | |
589 | - db_table = 'userlevel' | |
590 | - | |
591 | - def __str__(self): | |
592 | - return (str(self.name)) | |
593 | 605 | </pre> |
594 | 606 | |
595 | - <p><strong>Naming convention</strong> : Use self.name when possible, the creation time/date otherwise. Example :</p> | |
607 | + <a name="From-Eclipse-2"></a> | |
608 | +<h4 >From Eclipse<a href="#From-Eclipse-2" class="wiki-anchor">¶</a></h4> | |
596 | 609 | |
597 | 610 | |
598 | -<pre> | |
599 | -class SiteWatch(models.Model): | |
600 | - updated = models.DateTimeField(blank=True, null=True) | |
601 | - lights = models.CharField(max_length=45, blank=True, null=True) | |
602 | - dome = models.CharField(max_length=45, blank=True, null=True) | |
603 | - doors = models.CharField(max_length=45, blank=True, null=True) | |
604 | - temperature = models.FloatField(blank=True, null=True) | |
605 | - | |
606 | - class Meta: | |
607 | - managed = True | |
608 | - db_table = 'sitewatch' | |
609 | - | |
610 | - def __str__(self): | |
611 | - return (str(self.updated)) | |
612 | -</pre> | |
613 | - | |
614 | -<hr /> | |
611 | + <p>Right clic on project -> Django/Custom command/runserver</p> | |
615 | 612 | |
616 | 613 | |
617 | - <a name="Adaptation-of-the-one-to-many-and-many-to-many-display"></a> | |
618 | -<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> | |
614 | + <p>Error on Ubuntu :</p> | |
619 | 615 | |
620 | 616 | |
621 | - <ul> | |
622 | - <li>The one-to-many relationships are the following (One.many format) : | |
617 | +<pre> | |
623 | 618 | |
624 | - <ul> | |
625 | - <li>Schedule.sequences</li> | |
626 | - <li>Request.sequences</li> | |
627 | - <li>Sequence.albums</li> | |
628 | - <li>Album.plans</li> | |
629 | - <li>Plan.images</li> | |
630 | - <li>Telescope.detectors</li> | |
631 | - <li>Detector.filters</li> | |
632 | - <li>NrtAnalysis.images</li> | |
633 | - <li>Filter.plans</li> | |
634 | - <li>Detector.albums</li> | |
635 | - <li>UserLevel.users</li> | |
636 | - <li>Country.users</li> | |
637 | - <li>ScientificProgram.requests</li> | |
638 | - <li>User.requests</li> | |
639 | - <li>StrategyObs.alerts</li> | |
640 | - <li>SequenceType.sequences</li> | |
641 | - </ul></li> | |
642 | - </ul> | |
619 | +Traceback (most recent call last): | |
620 | + File "/home/carens_p/git/pyros/src/manage.py", line 8, in <module> | |
621 | + from django.core.management import execute_from_command_line | |
622 | +ImportError: No module named 'django' | |
643 | 623 | |
624 | +</pre> | |
644 | 625 | |
645 | - <ul> | |
646 | - <li>For each "many", create a new class in admin.py just after the imports, following these examples :</li> | |
647 | - </ul> | |
626 | + <p>Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed</p> | |
648 | 627 | |
649 | 628 | |
650 | -<pre> | |
629 | + <p>select venv_py35_pyros</p> | |
651 | 630 | |
652 | -For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need : | |
653 | 631 | |
654 | -class SequenceInline(admin.TabularInline): | |
655 | - model = Sequence | |
656 | - fields = ("name",) | |
657 | - show_change_link = True | |
632 | + <p>In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder.</p> | |
658 | 633 | |
659 | -For Sequence.albums and Detector.albums, we will need : | |
660 | 634 | |
661 | -class AlbumInline(admin.TabularInline): | |
662 | - model = Album | |
663 | - fields = ("name",) | |
664 | - show_change_link = True | |
635 | + <p>OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu</p> | |
665 | 636 | |
666 | -For StrategyObs.alerts, we will need : | |
667 | 637 | |
668 | -class AlertInline(admin.TabularInline): | |
669 | - model = Alert | |
670 | - fields = ("request.name",) # there is no 'name' attribute in the Alert model | |
671 | - show_change_link = True | |
638 | + <p>Then right clic on project -> Django/Custom command/runserver</p> | |
672 | 639 | |
673 | -</pre> | |
674 | 640 | |
675 | - <ul> | |
676 | - <li>For each "One", declare a new class in admin.py, just after the "Inlines" class declaration, as done in the following examples :</li> | |
677 | - </ul> | |
641 | + <p>check <a class="external" href="http://localhost:8000/">http://localhost:8000/</a></p> | |
678 | 642 | |
679 | 643 | |
680 | -<pre> | |
681 | -For Request.sequences : | |
644 | +<hr /> | |
682 | 645 | |
683 | -class RequestAdmin(admin.ModelAdmin): | |
684 | - inlines = [ | |
685 | - SequenceInline, | |
686 | - ] | |
687 | 646 | |
688 | -For Detector.filters and Detector.albums : | |
647 | + <a name="IV-TEST"></a> | |
648 | +<h2 ><span style="margin-left:0px;font-weight:bold;font-size:25px;color:red;">IV - TEST</span><a href="#IV-TEST" class="wiki-anchor">¶</a></h2> | |
689 | 649 | |
690 | -class DetectorAdmin(admin.ModelAdmin): | |
691 | - inlines = [ | |
692 | - FilterInline, | |
693 | - AlbumInline, | |
694 | - ] | |
695 | 650 | |
696 | -</pre> | |
651 | + <p>Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase</p> | |
697 | 652 | |
698 | - <ul> | |
699 | - <li>The many-to-many relationships are the following : | |
700 | 653 | |
701 | - <ul> | |
702 | - <li>ScientificProgram - User</li> | |
703 | - <li>ScheduleHistory - Sequence</li> | |
704 | - </ul></li> | |
705 | - </ul> | |
654 | + <p>You can run the tests suite, just to be sure that the software is well installed.</p> | |
706 | 655 | |
707 | 656 | |
708 | - <ul> | |
709 | - <li>For each many-to-many relationship, declare a new "Inline" class in admin.py just after the imports, like this :</li> | |
710 | - </ul> | |
657 | + <a name="From-Terminal"></a> | |
658 | +<h3 >From Terminal<a href="#From-Terminal" class="wiki-anchor">¶</a></h3> | |
711 | 659 | |
712 | 660 | |
713 | 661 | <pre> |
714 | -For ScientificProgram - User : | |
715 | - | |
716 | -class UserAndSPInline(admin.TabularInline): | |
717 | - model = ScientificProgram.users.through | |
662 | +$ cd src/ | |
718 | 663 | |
719 | -For ScheduleHistory - Sequence | |
664 | +$ ./manage.py test | |
720 | 665 | |
721 | -class SequenceAndSHInline(admin.TabularInline): | |
722 | - model = ScheduleHistory.sequences.through | |
666 | +Ran 5 tests in 0.093s | |
723 | 667 | |
668 | +OK | |
724 | 669 | </pre> |
725 | 670 | |
726 | - <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> | |
671 | + <a name="From-Eclipse-3"></a> | |
672 | +<h3 >From Eclipse:<a href="#From-Eclipse-3" class="wiki-anchor">¶</a></h3> | |
727 | 673 | |
728 | 674 | |
729 | 675 | <ul> |
730 | - <li>For each many-to-many relationship, declare two new classes in admin.py, just after the inlines, like in the following examples :</li> | |
676 | + <li>Right-clic on the project / Django / Run Django tests</li> | |
731 | 677 | </ul> |
732 | 678 | |
733 | 679 | |
734 | -<pre> | |
735 | -For the ScheduleHistory - Sequence relationship : | |
736 | - | |
737 | -class ScheduleHistoryAdmin(admin.ModelAdmin): | |
738 | - inlines = [ | |
739 | - SequenceAndSHInline, | |
740 | - ] | |
741 | - 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 | |
742 | - | |
743 | -class SequenceAdmin(admin.ModelAdmin): | |
744 | - inlines = [ | |
745 | - AlbumInline, # This is the Inline for the one-to-many relationship Sequence.albums | |
746 | - SequenceAndSHInline, | |
747 | - ] | |
748 | - | |
749 | -For the ScientificProgram - User relationship : | |
750 | - | |
751 | -class ScientificProgramAdmin(admin.ModelAdmin): | |
752 | - inlines = [ | |
753 | - RequestInline, | |
754 | - UserAndSPInline, | |
755 | - ] | |
756 | - exclude = ('users',) # Same as ScheduleHistory | |
757 | - | |
758 | -class UserAdmin(admin.ModelAdmin): | |
759 | - inlines = [ | |
760 | - RequestInline, # This is the Inline for the one-to-many relationship User.requests | |
761 | - UserAndSPInline, | |
762 | - ] | |
763 | - | |
764 | -</pre> | |
765 | - | |
766 | 680 | <ul> |
767 | - <li>For each ModelAdmin class in the admin.py, change the registering line</li> | |
681 | + <li>Right-clic on the project / Django / Custom command / ...</li> | |
768 | 682 | </ul> |
769 | 683 | |
770 | 684 | |
771 | -<pre> | |
772 | -admin.site.register(Album) | |
773 | -</pre> | |
774 | - | |
775 | - <p>to</p> | |
776 | - | |
777 | - | |
778 | -<pre> | |
779 | -admin.site.register(Album, AlbumAdmin) | |
780 | -</pre> | |
781 | - | |
782 | - <a name="V-INSTALLATION-FROM-THE-BEGINNING-for-dev-only-history-of-the-initial-project-creation"></a> | |
783 | -<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> | |
685 | + <a name="Custom-commands-"></a> | |
686 | +<h3 >Custom commands :<a href="#Custom-commands-" class="wiki-anchor">¶</a></h3> | |
784 | 687 | |
785 | 688 | |
786 | - <p><a href="Pyros_install_from_start.html" class="wiki-page">Pyros installation from the beginning</a></p> | |
689 | + <p>$ [./manage.py] test app.tests # Run tests for the application 'app'<br />$ [./manage.py] test app.tests.ModelTests # Run test methods declared in the class app.tests.ModelTests<br />$ [./manage.py] test app.tests.ModelTests.test_method # Only run the method test_method declared in app.tests.ModelTests</p> | |
787 | 690 | </body> |
788 | 691 | </html> | ... | ... |
install/INSTALLATION.pdf
No preview for this file type
install/INSTALLATION.txt
1 | -h1. Technical Documentation for the PYROS project (FGFT-CC) | |
1 | +h1. Project Installation | |
2 | 2 | |
3 | 3 | |
4 | +Project Development page : [[Project Development]] | |
5 | + | |
4 | 6 | HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting |
5 | 7 | |
6 | 8 | {{>toc}} |
... | ... | @@ -8,21 +10,6 @@ HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmi |
8 | 10 | |
9 | 11 | --- |
10 | 12 | |
11 | -h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}I - TODO% | |
12 | - | |
13 | - * installation sur windows | |
14 | - | |
15 | - * gitlab | |
16 | - | |
17 | - * séparation des BD Django et Pyros | |
18 | - | |
19 | - * intégration dans Eclipse | |
20 | - | |
21 | - * Intégration des modules Django déjà développés | |
22 | - | |
23 | - | |
24 | ---- | |
25 | - | |
26 | 13 | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}I - DATABASE SCHEMA (v0.2.1)% |
27 | 14 | |
28 | 15 | |
... | ... | @@ -33,29 +20,21 @@ h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:r |
33 | 20 | |
34 | 21 | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}II - Get the project (from gitlab)% |
35 | 22 | |
36 | -h3. Get the project from the terminal | |
37 | 23 | |
38 | -<pre> | |
39 | -git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS | |
24 | +h3. Browse the code from gitlab | |
40 | 25 | |
41 | -(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git) | |
42 | -</pre> | |
26 | +https://gitlab.irap.omp.eu/epallier/pyros/tree/master | |
43 | 27 | |
44 | -This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository) | |
28 | +h3. Project structure | |
45 | 29 | |
46 | -_If you just wanted a static copy of the project (without synchronization) just remove the .git/ folder:_ | |
47 | -<pre> | |
48 | -$ rm -r .git/ | |
49 | -</pre> | |
50 | - | |
51 | -You should obtain this structure: | |
30 | +Once you have fetched the project, you should obtain this structure: | |
52 | 31 | |
53 | 32 | <pre> |
54 | 33 | |
55 | 34 | PYROS/ |
56 | -├── REQUIREMENTS.txt | |
57 | -├── private/ | |
58 | -│ └── venv_py35_pyros/ | |
35 | +├── install/ | |
36 | +│ └── REQUIREMENTS.txt | |
37 | +│ └── INSTALLATION.txt | |
59 | 38 | ├── public/ |
60 | 39 | │ └── static/ |
61 | 40 | ├── src/ |
... | ... | @@ -78,13 +57,94 @@ PYROS/ |
78 | 57 | |
79 | 58 | </pre> |
80 | 59 | |
60 | +h3. From the terminal | |
61 | + | |
62 | +<pre> | |
63 | +git clone https://gitlab.irap.omp.eu/epallier/pyros.git PYROS | |
64 | +(or also : git clone git@gitlab.irap.omp.eu:epallier/pyros.git PYROS) | |
65 | +</pre> | |
81 | 66 | |
82 | -h3. Get the project from Eclipse | |
67 | +This creates a PYROS/ folder containing the project (with a .git/ subfolder for synchronization with the git repository) | |
83 | 68 | |
69 | +_If you just wanted a static copy of the project (without synchronization), just remove the .git/ folder:_ | |
84 | 70 | <pre> |
85 | -TODO: | |
71 | +$ rm -r .git/ | |
86 | 72 | </pre> |
87 | 73 | |
74 | +h3. From Eclipse | |
75 | + | |
76 | +0) Install Eclipse (if necessary) | |
77 | + | |
78 | +Get the Eclipse version for Php | |
79 | + | |
80 | +Install the plug-in pydev (via install new software, add http://pydev.org/updates) | |
81 | + | |
82 | + | |
83 | +1) Deactivate CA certificate verification | |
84 | + | |
85 | +Window -> Preferences -> Team -> git -> configuration -> Add entry | |
86 | + | |
87 | +Key = http.sslVerify | |
88 | +Value = false | |
89 | + | |
90 | +2) Fetch the project | |
91 | + | |
92 | +File/Import project from git | |
93 | + | |
94 | +Select repository source: Clone URI: https://gitlab.irap.omp.eu/epallier/pyros.git | |
95 | + | |
96 | +Directory: | |
97 | +par défaut, il propose : /Users/epallier/git/pyros | |
98 | +mais on peut le mettre ailleurs (c'est ce que j'ai fait) | |
99 | + | |
100 | +initial branch: master | |
101 | +remote name: origin | |
102 | + | |
103 | +Import as general project | |
104 | + | |
105 | +Project name: PYROS | |
106 | + | |
107 | + | |
108 | +3) Configure the project | |
109 | + | |
110 | +The project is created. Now, you have to set it as a «PyDev » and a « Django » project. | |
111 | + | |
112 | +clic droit sur le projet / PyDev / set as a PyDev project | |
113 | + | |
114 | +clic droit sur le projet / PyDev / set as a Django project | |
115 | + | |
116 | +clic droit sur le projet : on doit maintenant avoir un sous-menu Django | |
117 | + | |
118 | +clic droit sur le dossier src / PyDev / set as source folder (add to PYTHONPATH) | |
119 | + | |
120 | +clic droit sur projet / Properties / Pydev-Django : | |
121 | + - Django manage.py : src/manage.py | |
122 | + - Django settings module : pyros.settings | |
123 | + | |
124 | + | |
125 | +4) Set Code style | |
126 | + | |
127 | +Window/Preferences : Pydev / Editor | |
128 | +- Auto Imports : uncheck « Do auto import » | |
129 | +- Code style: | |
130 | + - Locals … : camelCase | |
131 | + - Methods : camelCase() with first lower | |
132 | +- Code style / Code Formatter: activer « use autopep8.py for code formatting » | |
133 | +- Tabs : Tab length : 4 | |
134 | + | |
135 | +( | |
136 | +il faudra aussi faire un peu plus loin : | |
137 | +https://projects.irap.omp.eu/projects/pyros/wiki/Project_Installation#Eclipse-only-Set-the-Python3-virtual-environment-as-the-project-interpreter | |
138 | +) | |
139 | + | |
140 | +h3. For easier installation, you can use Sqlite instead of Mysql | |
141 | + | |
142 | +By default, Mysql will be used, but then you will need to install the Mysql database server. | |
143 | + | |
144 | +Thus, in order to skip Mysql installation, use Sqlite instead as the database server (which will need no installation at all) : | |
145 | + | |
146 | +Edit pyros/settings.py and just set MYSQL variable to False, and that's it. | |
147 | + | |
88 | 148 | h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}III - INSTALLATION% |
89 | 149 | |
90 | 150 | |
... | ... | @@ -92,6 +152,8 @@ h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:r |
92 | 152 | |
93 | 153 | h3. Install MySql (only if necessary) |
94 | 154 | |
155 | +*Skip this step if you are using Sqlite instead of MySql* | |
156 | + | |
95 | 157 | * Linux Ubuntu |
96 | 158 | <pre> |
97 | 159 | |
... | ... | @@ -172,8 +234,8 @@ Open cmd (windows + R, cmd) : |
172 | 234 | TODO: |
173 | 235 | </pre> |
174 | 236 | |
175 | ---- | |
176 | - | |
237 | +--- | |
238 | + | |
177 | 239 | h3. Create a Python3 virtual environment dedicated to the project (inside the project folder) |
178 | 240 | |
179 | 241 | <pre> |
... | ... | @@ -190,8 +252,8 @@ $ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5 |
190 | 252 | |
191 | 253 | </pre> |
192 | 254 | |
193 | ---- | |
194 | - | |
255 | +--- | |
256 | + | |
195 | 257 | h3. Activate the python virtual environment (from inside the project) |
196 | 258 | |
197 | 259 | <pre> |
... | ... | @@ -229,8 +291,10 @@ Installing collected packages: wheel |
229 | 291 | Successfully installed wheel-0.29.0 |
230 | 292 | |
231 | 293 | |
232 | -</pre> | |
233 | - | |
294 | +</pre> | |
295 | + | |
296 | +--- | |
297 | + | |
234 | 298 | h3. Install the needed Python packages (from within the virtual environment) |
235 | 299 | |
236 | 300 | First, be sure that the virtual environment is activated: |
... | ... | @@ -356,7 +420,6 @@ YES !!! |
356 | 420 | $ pip install mysqlclient |
357 | 421 | Collecting mysqlclient |
358 | 422 | Downloading mysqlclient-1.3.7.tar.gz (79kB) |
359 | - 100% |████████████████████████████████| 81kB 1.5MB/s | |
360 | 423 | Complete output from command python setup.py egg_info: |
361 | 424 | /bin/sh: 1: mysql_config: not found |
362 | 425 | Traceback (most recent call last): |
... | ... | @@ -394,246 +457,113 @@ YES !!! |
394 | 457 | |
395 | 458 | </pre> |
396 | 459 | |
397 | ---- | |
398 | - | |
399 | -h3. Test the project | |
400 | - | |
460 | + * => Issue under Windows | |
401 | 461 | <pre> |
462 | +Same message as the issue for Mac. | |
402 | 463 | |
403 | -$ cd src/ | |
464 | +Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient to download the newest mysqlclient wheel | |
404 | 465 | |
405 | -$ ./manage.py runserver | |
406 | -(or gunicorn pyros.wsgi) | |
407 | -==> http://localhost:8000 | |
408 | -... | |
409 | -... | |
410 | -Ctrl-c | |
466 | +$ pip install path\to\mysqlclient\wheel | |
411 | 467 | |
468 | +No need to redo "pip install mysqlclient" | |
412 | 469 | </pre> |
413 | 470 | |
414 | - | |
415 | - | |
416 | ---- | |
417 | - | |
418 | -h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}IV - CONFIGURATION of the Django Back Office (administration interface)% | |
419 | - | |
420 | 471 | --- |
421 | 472 | |
422 | -h3. Back Office setup | |
473 | +h3. (Eclipse only) Set the Python3 virtual environment as the project interpreter | |
423 | 474 | |
424 | - * Prerequisites in src/pyros/settings.py : | |
475 | +clic droit sur projet / Properties / PyDev - Interpreter/Grammar : | |
476 | +Grammar version : 3 | |
425 | 477 | |
426 | - * INSTALLED_APPS must (at least) contain : | |
478 | +Interpreter : click on « click here to configure an interpreter not listed » | |
427 | 479 | |
428 | - * django.contrib.admin | |
429 | - * django.contrib.auth | |
430 | - * django.contrib.contenttypes | |
431 | - * django.contrib.sessions | |
480 | +click on « New » : | |
481 | +- Interpreter name : venv_py35_pyros | |
482 | +- Interpreter executable : click on « Browse » | |
483 | + Select your private/venv_py35_pyros/bin/python3.5 executable | |
484 | + click OK | |
485 | + click OK again | |
432 | 486 | |
433 | - * MIDDLEWARES must (at least) contain : | |
487 | +Interpreter: select now venv_py35_pyros from the list | |
434 | 488 | |
435 | - * django.contrib.sessions.middleware.SessionMiddleware | |
436 | - * django.middleware.common.CommonMiddleware | |
437 | - * django.contrib.auth.middleware.AuthenticationMiddleware | |
438 | - | |
439 | - * At least one 'python manage.py migrate' must have been executed | |
489 | +--- | |
440 | 490 | |
441 | - * Create a superuser for the administration : | |
491 | +h3. Run the project | |
442 | 492 | |
443 | -<pre> | |
444 | -$ python manage.py createsuperuser | |
445 | -</pre> | |
493 | +TODO: more details... (notamment sur localhost:8000/admin) | |
446 | 494 | |
447 | -* For each app of the project, fill the admin.py file : | |
495 | +h4. From the terminal | |
448 | 496 | |
449 | 497 | <pre> |
450 | -from django.contrib import admin | |
451 | -from app.models import Model1, Model2 | |
452 | 498 | |
453 | -admin.site.register(Model1) | |
454 | -admin.site.register(Model2) | |
455 | -</pre> | |
456 | - | |
457 | -*Reminder* : each application must be registered in the settings.py INSTALLED_APPS variable. | |
458 | - | |
459 | -* For each model in models.py, add a '__str__()' method in order to identify the object on the back office. Example : | |
460 | - | |
461 | -<pre> | |
462 | -class UserLevel(models.Model): | |
463 | - name = models.CharField(max_length=45, blank=True, null=True) | |
464 | - desc = models.TextField(blank=True, null=True) | |
465 | - priority = models.IntegerField(blank=True, null=True) | |
466 | - quota = models.FloatField(blank=True, null=True) | |
467 | - | |
468 | - class Meta: | |
469 | - managed = True | |
470 | - db_table = 'userlevel' | |
471 | - | |
472 | - def __str__(self): | |
473 | - return (str(self.name)) | |
474 | -</pre> | |
499 | +$ cd src/ | |
475 | 500 | |
476 | -*Naming convention* : Use self.name when possible, the creation time/date otherwise. Example : | |
501 | +$ ./manage.py runserver | |
502 | +(or gunicorn pyros.wsgi) | |
503 | +==> http://localhost:8000 | |
504 | +... | |
505 | +... | |
506 | +Ctrl-c | |
477 | 507 | |
478 | -<pre> | |
479 | -class SiteWatch(models.Model): | |
480 | - updated = models.DateTimeField(blank=True, null=True) | |
481 | - lights = models.CharField(max_length=45, blank=True, null=True) | |
482 | - dome = models.CharField(max_length=45, blank=True, null=True) | |
483 | - doors = models.CharField(max_length=45, blank=True, null=True) | |
484 | - temperature = models.FloatField(blank=True, null=True) | |
485 | - | |
486 | - class Meta: | |
487 | - managed = True | |
488 | - db_table = 'sitewatch' | |
489 | - | |
490 | - def __str__(self): | |
491 | - return (str(self.updated)) | |
492 | 508 | </pre> |
493 | 509 | |
494 | ---- | |
495 | - | |
496 | -h3. Adaptation of the one-to-many and many-to-many display | |
497 | - | |
498 | -* The one-to-many relationships are the following (One.many format) : | |
499 | - | |
500 | - * Schedule.sequences | |
501 | - * Request.sequences | |
502 | - * Sequence.albums | |
503 | - * Album.plans | |
504 | - * Plan.images | |
505 | - * Telescope.detectors | |
506 | - * Detector.filters | |
507 | - * NrtAnalysis.images | |
508 | - * Filter.plans | |
509 | - * Detector.albums | |
510 | - * UserLevel.users | |
511 | - * Country.users | |
512 | - * ScientificProgram.requests | |
513 | - * User.requests | |
514 | - * StrategyObs.alerts | |
515 | - * SequenceType.sequences | |
516 | - | |
517 | -* For each "many", create a new class in admin.py just after the imports, following these examples : | |
518 | - | |
519 | -<pre> | |
520 | - | |
521 | -For Schedule.sequences, Request.sequences and Sequentype.sequences, we will need : | |
522 | - | |
523 | -class SequenceInline(admin.TabularInline): | |
524 | - model = Sequence | |
525 | - fields = ("name",) | |
526 | - show_change_link = True | |
527 | - | |
528 | - | |
529 | -For Sequence.albums and Detector.albums, we will need : | |
530 | - | |
531 | -class AlbumInline(admin.TabularInline): | |
532 | - model = Album | |
533 | - fields = ("name",) | |
534 | - show_change_link = True | |
535 | - | |
510 | +h4. From Eclipse | |
536 | 511 | |
537 | -For StrategyObs.alerts, we will need : | |
512 | +Right clic on project -> Django/Custom command/runserver | |
538 | 513 | |
539 | -class AlertInline(admin.TabularInline): | |
540 | - model = Alert | |
541 | - fields = ("request.name",) # there is no 'name' attribute in the Alert model | |
542 | - show_change_link = True | |
543 | - | |
544 | -</pre> | |
545 | - | |
546 | -* For each "One", declare a new class in admin.py, just after the "Inlines" class declaration, as done in the following examples : | |
514 | +Error on Ubuntu : | |
547 | 515 | |
548 | 516 | <pre> |
549 | -For Request.sequences : | |
550 | - | |
551 | -class RequestAdmin(admin.ModelAdmin): | |
552 | - inlines = [ | |
553 | - SequenceInline, | |
554 | - ] | |
555 | 517 | |
556 | -For Detector.filters and Detector.albums : | |
557 | - | |
558 | -class DetectorAdmin(admin.ModelAdmin): | |
559 | - inlines = [ | |
560 | - FilterInline, | |
561 | - AlbumInline, | |
562 | - ] | |
518 | +Traceback (most recent call last): | |
519 | + File "/home/carens_p/git/pyros/src/manage.py", line 8, in <module> | |
520 | + from django.core.management import execute_from_command_line | |
521 | +ImportError: No module named 'django' | |
563 | 522 | |
564 | 523 | </pre> |
565 | 524 | |
525 | +Project -> Properties -> Pydev interpreter -> Clic here to configure an interpreter not listed | |
566 | 526 | |
567 | -* The many-to-many relationships are the following : | |
527 | +select venv_py35_pyros | |
568 | 528 | |
569 | - * ScientificProgram - User | |
570 | - * ScheduleHistory - Sequence | |
529 | +In Libraries, clic on 'New folder', then select your virtualenv's lib/python3.5/site-packages folder. | |
571 | 530 | |
572 | -* For each many-to-many relationship, declare a new "Inline" class in admin.py just after the imports, like this : | |
531 | +OK -> re-select venv_py35_pyros in 'Interpreter' dropdown menu | |
573 | 532 | |
574 | -<pre> | |
575 | -For ScientificProgram - User : | |
533 | +Then right clic on project -> Django/Custom command/runserver | |
576 | 534 | |
577 | -class UserAndSPInline(admin.TabularInline): | |
578 | - model = ScientificProgram.users.through | |
535 | +check http://localhost:8000/ | |
579 | 536 | |
580 | 537 | |
581 | -For ScheduleHistory - Sequence | |
538 | +--- | |
539 | + | |
540 | +h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}IV - TEST% | |
582 | 541 | |
583 | -class SequenceAndSHInline(admin.TabularInline): | |
584 | - model = ScheduleHistory.sequences.through | |
542 | +Tests are classes declared in all apps' test.py file. The test classes inherit from django.test.TestCase | |
585 | 543 | |
586 | -</pre> | |
544 | +You can run the tests suite, just to be sure that the software is well installed. | |
587 | 545 | |
588 | -+Note :+ 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. | |
546 | +h3. From Terminal | |
589 | 547 | |
590 | -* For each many-to-many relationship, declare two new classes in admin.py, just after the inlines, like in the following examples : | |
591 | 548 | |
592 | 549 | <pre> |
593 | -For the ScheduleHistory - Sequence relationship : | |
594 | - | |
595 | -class ScheduleHistoryAdmin(admin.ModelAdmin): | |
596 | - inlines = [ | |
597 | - SequenceAndSHInline, | |
598 | - ] | |
599 | - 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 | |
600 | - | |
601 | -class SequenceAdmin(admin.ModelAdmin): | |
602 | - inlines = [ | |
603 | - AlbumInline, # This is the Inline for the one-to-many relationship Sequence.albums | |
604 | - SequenceAndSHInline, | |
605 | - ] | |
606 | - | |
607 | -For the ScientificProgram - User relationship : | |
608 | - | |
609 | -class ScientificProgramAdmin(admin.ModelAdmin): | |
610 | - inlines = [ | |
611 | - RequestInline, | |
612 | - UserAndSPInline, | |
613 | - ] | |
614 | - exclude = ('users',) # Same as ScheduleHistory | |
615 | - | |
616 | -class UserAdmin(admin.ModelAdmin): | |
617 | - inlines = [ | |
618 | - RequestInline, # This is the Inline for the one-to-many relationship User.requests | |
619 | - UserAndSPInline, | |
620 | - ] | |
550 | +$ cd src/ | |
621 | 551 | |
622 | -</pre> | |
552 | +$ ./manage.py test | |
623 | 553 | |
624 | -* For each ModelAdmin class in the admin.py, change the registering line | |
554 | +Ran 5 tests in 0.093s | |
625 | 555 | |
626 | -<pre> | |
627 | -admin.site.register(Album) | |
556 | +OK | |
628 | 557 | </pre> |
629 | 558 | |
630 | -to | |
559 | +h3. From Eclipse: | |
631 | 560 | |
632 | -<pre> | |
633 | -admin.site.register(Album, AlbumAdmin) | |
634 | -</pre> | |
635 | - | |
636 | -h2. %{margin-left:0px; font-weight:bold; font-size:25px; display:block; color:red;}V - INSTALLATION FROM THE BEGINNING (for dev only, history of the initial project creation)% | |
561 | +* Right-clic on the project / Django / Run Django tests | |
562 | + | |
563 | +* Right-clic on the project / Django / Custom command / ... | |
637 | 564 | |
565 | +h3. Custom commands : | |
638 | 566 | |
639 | -[[pyros_install_from_start|Pyros installation from the beginning]] | |
567 | +$ [./manage.py] test app.tests # Run tests for the application 'app' | |
568 | +$ [./manage.py] test app.tests.ModelTests # Run test methods declared in the class app.tests.ModelTests | |
569 | +$ [./manage.py] test app.tests.ModelTests.test_method # Only run the method test_method declared in app.tests.ModelTests | |
640 | 570 | \ No newline at end of file | ... | ... |