core-module-periodic-table-app 2.18.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. core_module_periodic_table_app-2.18.0/LICENSE.md +35 -0
  2. core_module_periodic_table_app-2.18.0/MANIFEST.in +5 -0
  3. core_module_periodic_table_app-2.18.0/PKG-INFO +33 -0
  4. core_module_periodic_table_app-2.18.0/README.rst +24 -0
  5. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/__init__.py +0 -0
  6. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/static/core_module_periodic_table_app/css/periodic.css +83 -0
  7. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/static/core_module_periodic_table_app/js/periodic.js +33 -0
  8. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/templates/core_module_periodic_table_app/periodic.html +148 -0
  9. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/templates/core_module_periodic_table_app/periodic_simple.html +4 -0
  10. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/urls.py +14 -0
  11. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app/views.py +63 -0
  12. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app.egg-info/PKG-INFO +33 -0
  13. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app.egg-info/SOURCES.txt +22 -0
  14. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app.egg-info/dependency_links.txt +1 -0
  15. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app.egg-info/requires.txt +2 -0
  16. core_module_periodic_table_app-2.18.0/core_module_periodic_table_app.egg-info/top_level.txt +2 -0
  17. core_module_periodic_table_app-2.18.0/pyproject.toml +5 -0
  18. core_module_periodic_table_app-2.18.0/requirements.core.txt +1 -0
  19. core_module_periodic_table_app-2.18.0/requirements.txt +1 -0
  20. core_module_periodic_table_app-2.18.0/setup.cfg +4 -0
  21. core_module_periodic_table_app-2.18.0/setup.py +38 -0
  22. core_module_periodic_table_app-2.18.0/tests/__init__.py +0 -0
  23. core_module_periodic_table_app-2.18.0/tests/test_settings.py +46 -0
  24. core_module_periodic_table_app-2.18.0/tests/test_unit_views.py +125 -0
@@ -0,0 +1,35 @@
1
+ # NIST Software Licensing Statement
2
+
3
+ NIST-developed software is provided by NIST as a public service.
4
+ You may use, copy, and distribute copies of the software in any
5
+ medium, provided that you keep intact this entire notice. You may
6
+ improve, modify, and create derivative works of the software or
7
+ any portion of the software, and you may copy and distribute such
8
+ modifications or works. Modified works should carry a notice
9
+ stating that you changed the software and should note the date
10
+ and nature of any such change. Please explicitly acknowledge the
11
+ National Institute of Standards and Technology as the source of
12
+ the software.
13
+
14
+ NIST-developed software is expressly provided "AS IS." NIST MAKES
15
+ NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT, OR ARISING BY
16
+ OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17
+ WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
18
+ NON-INFRINGEMENT, AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR
19
+ WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED
20
+ OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES
21
+ NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE
22
+ SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE
23
+ CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE
24
+ SOFTWARE.
25
+
26
+ You are solely responsible for determining the appropriateness of
27
+ using and distributing the software and you assume all risks
28
+ associated with its use, including but not limited to the risks
29
+ and costs of program errors, compliance with applicable laws,
30
+ damage to or loss of data, programs or equipment, and the
31
+ unavailability or interruption of operation. This software is not
32
+ intended to be used in any situation where a failure could cause
33
+ risk of injury or damage to property. The software developed by
34
+ NIST employees is not subject to copyright protection within the
35
+ United States.
@@ -0,0 +1,5 @@
1
+ include README.rst
2
+ include requirements.txt
3
+ include requirements.core.txt
4
+ recursive-include core_module_periodic_table_app/static *
5
+ recursive-include core_module_periodic_table_app/templates *
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.1
2
+ Name: core_module_periodic_table_app
3
+ Version: 2.18.0
4
+ Summary: Periodic table module for the parser core project
5
+ Home-page: https://github.com/usnistgov/core_module_periodic_table_app
6
+ Author: NIST IT Lab
7
+ Author-email: itl_inquiries@nist.gov
8
+ License-File: LICENSE.md
9
+
10
+ core_module_periodic_table_app
11
+ ==============================
12
+
13
+ Periodic Table module for the parser core project.
14
+
15
+ Quick start
16
+ ===========
17
+
18
+ 1. Add "core_module_periodic_table_app" to your INSTALLED_APPS setting
19
+ ----------------------------------------------------------------------
20
+
21
+ .. code:: python
22
+
23
+ INSTALLED_APPS = [
24
+ ...
25
+ 'core_module_periodic_table_app',
26
+ ]
27
+
28
+ 2. Include the core_module_periodic_table_app URLconf in your project urls.py
29
+ -----------------------------------------------------------------------------
30
+
31
+ .. code:: python
32
+
33
+ url(r'^', include('core_module_periodic_table_app.urls')),
@@ -0,0 +1,24 @@
1
+ core_module_periodic_table_app
2
+ ==============================
3
+
4
+ Periodic Table module for the parser core project.
5
+
6
+ Quick start
7
+ ===========
8
+
9
+ 1. Add "core_module_periodic_table_app" to your INSTALLED_APPS setting
10
+ ----------------------------------------------------------------------
11
+
12
+ .. code:: python
13
+
14
+ INSTALLED_APPS = [
15
+ ...
16
+ 'core_module_periodic_table_app',
17
+ ]
18
+
19
+ 2. Include the core_module_periodic_table_app URLconf in your project urls.py
20
+ -----------------------------------------------------------------------------
21
+
22
+ .. code:: python
23
+
24
+ url(r'^', include('core_module_periodic_table_app.urls')),
@@ -0,0 +1,83 @@
1
+ .periodic-table {
2
+ background-color: white;
3
+ border: 0;
4
+ border-collapse: collapse;
5
+ }
6
+
7
+ table.periodic-table tr {
8
+ vertical-align: middle;
9
+ text-align: left;
10
+ }
11
+
12
+ table.periodic-table tr td {
13
+ background-color: white;
14
+ padding: 6px;
15
+ border: 1px solid white;
16
+
17
+ text-align: center;
18
+ }
19
+
20
+ table.periodic-table tr td.p-elem {
21
+ cursor: pointer;
22
+ }
23
+
24
+ table.periodic-table tr td.p-elem:hover {
25
+ background-color: #FFFF80;
26
+ }
27
+
28
+ table.periodic-table tr td.p-elem.selected {
29
+ background-color: #FFFF80;
30
+ }
31
+
32
+ table.periodic-table tr td.title {
33
+ font-size: small;
34
+ vertical-align: top;
35
+ }
36
+
37
+ table.periodic-table tr td.c-header {
38
+ vertical-align: bottom;
39
+ font-size: x-small;
40
+ }
41
+
42
+ table.periodic-table tr td.r-header {
43
+ text-align: right;
44
+ font-size: small;
45
+ }
46
+
47
+ table.periodic-table tr td.green {
48
+ background-color: #b0ffb0;
49
+ }
50
+
51
+ table.periodic-table tr td.blue {
52
+ background-color: #a0a0ff;
53
+ }
54
+
55
+ table.periodic-table tr td.lightblue {
56
+ background-color: #a0c0ff;
57
+ }
58
+
59
+ table.periodic-table tr td.cyan {
60
+ background-color: #c0ffff;
61
+ }
62
+
63
+ table.periodic-table tr td.purple {
64
+ background-color: #e080e0;
65
+ }
66
+
67
+ table.periodic-table tr td.yellow {
68
+ background-color: #ffe080;
69
+ }
70
+
71
+ table.periodic-table tr td.orange {
72
+ background-color: #ffa080;
73
+ }
74
+
75
+ table.periodic-table tr td.gray {
76
+ background-color: #e0e0e0;
77
+ }
78
+
79
+ table.periodic-table tr td.darkgray {
80
+ background-color: #c0c0c0;
81
+ }
82
+
83
+
@@ -0,0 +1,33 @@
1
+ /** Periodic table module script */
2
+ savePeriodicTableData = function() {
3
+ let jqModuleOpenModal = $($("#modal-" + moduleElement[0].id)[0]);
4
+ let selectedElement = jqModuleOpenModal.find('.periodic-table .selected');
5
+
6
+ jqModuleOpenModal.find('.periodic-table-keep-state').text("true");
7
+
8
+ $.each(jqModuleOpenModal.find('.periodic-table').find('.orig-selected'), function(index, element) {
9
+ $(element).removeClass('orig-selected');
10
+ });
11
+ selectedElement.addClass('orig-selected');
12
+
13
+ return {'selectedElement': selectedElement.text()};
14
+ };
15
+
16
+ var periodicTablePopupOptions = {
17
+ title: "Select Element",
18
+ getData: savePeriodicTableData
19
+ };
20
+
21
+ // Selection highlight
22
+ $(document).on('click', '.periodic-table-simple td.p-elem', function(event) {
23
+
24
+ var pTable = $($("#modal-" + moduleElement[0].id)[0]).find('.periodic-table');
25
+ $.each(pTable.find('.selected'), function(index, element) {
26
+ $(element).removeClass('selected');
27
+ });
28
+
29
+ $(this).addClass('selected');
30
+ });
31
+
32
+
33
+ configurePopUp('module-periodic-table', periodicTablePopupOptions);
@@ -0,0 +1,148 @@
1
+ <tr>
2
+ <td></td>
3
+ <td class="c-header">IA</td>
4
+ <td colspan="16"></td>
5
+ <td class="c-header">0</td>
6
+ </tr><tr>
7
+ <td class="r-header">1</td>
8
+ <td class="p-elem green {% if 'H' in selected_elements %} selected {% endif %}">H</td>
9
+ <td class="c-header">IIA</td>
10
+ <td colspan="10" class="title">Select one element by clicking on the element.</td>
11
+ <td class="c-header">IIIA</td>
12
+ <td class="c-header">IVA</td>
13
+ <td class="c-header">VA</td>
14
+ <td class="c-header">VIA</td>
15
+ <td class="c-header">VIIA</td>
16
+ <td class="p-elem orange {% if 'He' in selected_elements %} selected {% endif %}">He</td>
17
+ </tr><tr>
18
+ <td class="r-header">2</td>
19
+ <td class="p-elem blue {% if 'Li' in selected_elements %} selected {% endif %}">Li</td>
20
+ <td class="p-elem lightblue {% if 'Be' in selected_elements %} selected {% endif %}">Be</td>
21
+ <td colspan="10"></td>
22
+ <td class="p-elem purple {% if 'B' in selected_elements %} selected {% endif %}">B</td>
23
+ <td class="p-elem green {% if 'C' in selected_elements %} selected {% endif %}">C</td>
24
+ <td class="p-elem green {% if 'N' in selected_elements %} selected {% endif %}">N</td>
25
+ <td class="p-elem green {% if 'O' in selected_elements %} selected {% endif %}">O</td>
26
+ <td class="p-elem yellow {% if 'F' in selected_elements %} selected {% endif %}">F</td>
27
+ <td class="p-elem orange {% if 'Ne' in selected_elements %} selected {% endif %}">Ne</td>
28
+ </tr><tr>
29
+ <td class="r-header">3</td>
30
+ <td class="p-elem blue {% if 'Na' in selected_elements %} selected {% endif %}">Na</td>
31
+ <td class="p-elem lightblue {% if 'Mg' in selected_elements %} selected {% endif %}">Mg</td>
32
+ <td class="c-header">IIIB</td>
33
+ <td class="c-header">IVB</td>
34
+ <td class="c-header">VB</td>
35
+ <td class="c-header">VIB</td>
36
+ <td class="c-header" colspan="3">VIIB</td>
37
+ <td class="c-header">VIIIB</td>
38
+ <td class="c-header">IB</td>
39
+ <td class="c-header">IIB</td>
40
+ <td class="p-elem cyan {% if 'Al' in selected_elements %} selected {% endif %}">Al</td>
41
+ <td class="p-elem purple {% if 'Si' in selected_elements %} selected {% endif %}">Si</td>
42
+ <td class="p-elem green {% if 'P' in selected_elements %} selected {% endif %}">P</td>
43
+ <td class="p-elem green {% if 'S' in selected_elements %} selected {% endif %}">S</td>
44
+ <td class="p-elem yellow {% if 'Cl' in selected_elements %} selected {% endif %}">Cl</td>
45
+ <td class="p-elem orange {% if 'Ar' in selected_elements %} selected {% endif %}">Ar</td>
46
+ </tr><tr>
47
+ <td class="r-header">4</td>
48
+ <td class="p-elem blue {% if 'k' in selected_elements %} selected {% endif %}">K</td>
49
+ <td class="p-elem lightblue {% if 'Ca' in selected_elements %} selected {% endif %}">Ca</td>
50
+ <td class="p-elem gray {% if 'Sc' in selected_elements %} selected {% endif %}">Sc</td>
51
+ <td class="p-elem gray {% if 'Ti' in selected_elements %} selected {% endif %}">Ti</td>
52
+ <td class="p-elem gray {% if 'V' in selected_elements %} selected {% endif %}">V</td>
53
+ <td class="p-elem gray {% if 'Cr' in selected_elements %} selected {% endif %}">Cr</td>
54
+ <td class="p-elem gray {% if 'Mn' in selected_elements %} selected {% endif %}">Mn</td>
55
+ <td class="p-elem gray {% if 'Fe' in selected_elements %} selected {% endif %}">Fe</td>
56
+ <td class="p-elem gray {% if 'Co' in selected_elements %} selected {% endif %}">Co</td>
57
+ <td class="p-elem gray {% if 'Ni' in selected_elements %} selected {% endif %}">Ni</td>
58
+ <td class="p-elem gray {% if 'Cu' in selected_elements %} selected {% endif %}">Cu</td>
59
+ <td class="p-elem gray {% if 'Zn' in selected_elements %} selected {% endif %}">Zn</td>
60
+ <td class="p-elem cyan {% if 'Ga' in selected_elements %} selected {% endif %}">Ga</td>
61
+ <td class="p-elem purple {% if 'Ge' in selected_elements %} selected {% endif %}">Ge</td>
62
+ <td class="p-elem purple {% if 'As' in selected_elements %} selected {% endif %}">As</td>
63
+ <td class="p-elem green {% if 'Se' in selected_elements %} selected {% endif %}">Se</td>
64
+ <td class="p-elem yellow {% if 'Br' in selected_elements %} selected {% endif %}">Br</td>
65
+ <td class="p-elem orange {% if 'Kr' in selected_elements %} selected {% endif %}">Kr</td>
66
+ </tr><tr>
67
+ <td class="r-header">5</td>
68
+ <td class="p-elem blue {% if 'Rb' in selected_elements %} selected {% endif %}">Rb</td>
69
+ <td class="p-elem lightblue {% if 'Sr' in selected_elements %} selected {% endif %}">Sr</td>
70
+ <td class="p-elem gray {% if 'Y' in selected_elements %} selected {% endif %}">Y</td>
71
+ <td class="p-elem gray {% if 'Zr' in selected_elements %} selected {% endif %}">Zr</td>
72
+ <td class="p-elem gray {% if 'Nb' in selected_elements %} selected {% endif %}">Nb</td>
73
+ <td class="p-elem gray {% if 'Mo' in selected_elements %} selected {% endif %}">Mo</td>
74
+ <td class="p-elem gray {% if 'Tc' in selected_elements %} selected {% endif %}">Tc</td>
75
+ <td class="p-elem gray {% if 'Ru' in selected_elements %} selected {% endif %}">Ru</td>
76
+ <td class="p-elem gray {% if 'Rh' in selected_elements %} selected {% endif %}">Rh</td>
77
+ <td class="p-elem gray {% if 'Pd' in selected_elements %} selected {% endif %}">Pd</td>
78
+ <td class="p-elem gray {% if 'Ag' in selected_elements %} selected {% endif %}">Ag</td>
79
+ <td class="p-elem gray {% if 'Cd' in selected_elements %} selected {% endif %}">Cd</td>
80
+ <td class="p-elem cyan {% if 'In' in selected_elements %} selected {% endif %}">In</td>
81
+ <td class="p-elem cyan {% if 'Sn' in selected_elements %} selected {% endif %}">Sn</td>
82
+ <td class="p-elem purple {% if 'Sb' in selected_elements %} selected {% endif %}">Sb</td>
83
+ <td class="p-elem purple {% if 'Te' in selected_elements %} selected {% endif %}">Te</td>
84
+ <td class="p-elem yellow {% if 'I' in selected_elements %} selected {% endif %}">I</td>
85
+ <td class="p-elem orange {% if 'Xe' in selected_elements %} selected {% endif %}">Xe</td>
86
+ </tr><tr>
87
+ <td class="r-header">6</td>
88
+ <td class="p-elem blue {% if 'Cs' in selected_elements %} selected {% endif %}">Cs</td>
89
+ <td class="p-elem lightblue {% if 'Ba' in selected_elements %} selected {% endif %}">Ba</td>
90
+ <td class="p-elem gray {% if 'La' in selected_elements %} selected {% endif %}">La</td>
91
+ <td class="p-elem gray {% if 'Hf' in selected_elements %} selected {% endif %}">Hf</td>
92
+ <td class="p-elem gray {% if 'Ta' in selected_elements %} selected {% endif %}">Ta</td>
93
+ <td class="p-elem gray {% if 'W' in selected_elements %} selected {% endif %}">W</td>
94
+ <td class="p-elem gray {% if 'Re' in selected_elements %} selected {% endif %}">Re</td>
95
+ <td class="p-elem gray {% if 'Os' in selected_elements %} selected {% endif %}">Os</td>
96
+ <td class="p-elem gray {% if 'Ir' in selected_elements %} selected {% endif %}">Ir</td>
97
+ <td class="p-elem gray {% if 'Pt' in selected_elements %} selected {% endif %}">Pt</td>
98
+ <td class="p-elem gray {% if 'Au' in selected_elements %} selected {% endif %}">Au</td>
99
+ <td class="p-elem gray {% if 'Hg' in selected_elements %} selected {% endif %}">Hg</td>
100
+ <td class="p-elem cyan {% if 'Tl' in selected_elements %} selected {% endif %}">Tl</td>
101
+ <td class="p-elem cyan {% if 'Pb' in selected_elements %} selected {% endif %}">Pb</td>
102
+ <td class="p-elem cyan {% if 'Bi' in selected_elements %} selected {% endif %}">Bi</td>
103
+ <td class="p-elem purple {% if 'Po' in selected_elements %} selected {% endif %}">Po</td>
104
+ <td class="p-elem yellow {% if 'At' in selected_elements %} selected {% endif %}">At</td>
105
+ <td class="p-elem orange {% if 'Rn' in selected_elements %} selected {% endif %}">Rn</td>
106
+ </tr><tr>
107
+ <td class="r-header">7</td>
108
+ <td class="p-elem blue {% if 'Fr' in selected_elements %} selected {% endif %}">Fr</td>
109
+ <td class="p-elem lightblue {% if 'Ra' in selected_elements %} selected {% endif %}">Ra</td>
110
+ <td class="p-elem gray {% if 'Ac' in selected_elements %} selected {% endif %}">Ac</td>
111
+ <td colspan="12"></td>
112
+ </tr><tr>
113
+ <td colspan="19"></td>
114
+ </tr><tr>
115
+ <td colspan="4" class="r-header">Lanthanides</td>
116
+ <td class="p-elem darkgray {% if 'Ce' in selected_elements %} selected {% endif %}">Ce</td>
117
+ <td class="p-elem darkgray {% if 'Pr' in selected_elements %} selected {% endif %}">Pr</td>
118
+ <td class="p-elem darkgray {% if 'Nd' in selected_elements %} selected {% endif %}">Nd</td>
119
+ <td class="p-elem darkgray {% if 'Pm' in selected_elements %} selected {% endif %}">Pm</td>
120
+ <td class="p-elem darkgray {% if 'Sm' in selected_elements %} selected {% endif %}">Sm</td>
121
+ <td class="p-elem darkgray {% if 'Eu' in selected_elements %} selected {% endif %}">Eu</td>
122
+ <td class="p-elem darkgray {% if 'Gd' in selected_elements %} selected {% endif %}">Gd</td>
123
+ <td class="p-elem darkgray {% if 'Tb' in selected_elements %} selected {% endif %}">Tb</td>
124
+ <td class="p-elem darkgray {% if 'Dy' in selected_elements %} selected {% endif %}">Dy</td>
125
+ <td class="p-elem darkgray {% if 'Ho' in selected_elements %} selected {% endif %}">Ho</td>
126
+ <td class="p-elem darkgray {% if 'Er' in selected_elements %} selected {% endif %}">Er</td>
127
+ <td class="p-elem darkgray {% if 'Tm' in selected_elements %} selected {% endif %}">Tm</td>
128
+ <td class="p-elem darkgray {% if 'Yb' in selected_elements %} selected {% endif %}">Yb</td>
129
+ <td class="p-elem darkgray {% if 'Lu' in selected_elements %} selected {% endif %}">Lu</td>
130
+ <td></td>
131
+ </tr><tr>
132
+ <td colspan="4" class="r-header">Actinides</td>
133
+ <td class="p-elem darkgray {% if 'Th' in selected_elements %} selected {% endif %}">Th</td>
134
+ <td class="p-elem darkgray {% if 'Pa' in selected_elements %} selected {% endif %}">Pa</td>
135
+ <td class="p-elem darkgray {% if 'U' in selected_elements %} selected {% endif %}">U</td>
136
+ <td class="p-elem darkgray {% if 'Np' in selected_elements %} selected {% endif %}">Np</td>
137
+ <td class="p-elem darkgray {% if 'Pu' in selected_elements %} selected {% endif %}">Pu</td>
138
+ <td class="p-elem darkgray {% if 'Am' in selected_elements %} selected {% endif %}">Am</td>
139
+ <td class="p-elem darkgray {% if 'Cm' in selected_elements %} selected {% endif %}">Cm</td>
140
+ <td class="p-elem darkgray {% if 'Bk' in selected_elements %} selected {% endif %}">Bk</td>
141
+ <td class="p-elem darkgray {% if 'Cf' in selected_elements %} selected {% endif %}">Cf</td>
142
+ <td class="p-elem darkgray {% if 'Es' in selected_elements %} selected {% endif %}">Es</td>
143
+ <td class="p-elem darkgray {% if 'Fm' in selected_elements %} selected {% endif %}">Fm</td>
144
+ <td class="p-elem darkgray {% if 'Md' in selected_elements %} selected {% endif %}">Md</td>
145
+ <td class="p-elem darkgray {% if 'No' in selected_elements %} selected {% endif %}">No</td>
146
+ <td class="p-elem darkgray {% if 'Lr' in selected_elements %} selected {% endif %}">Lr</td>
147
+ <td></td>
148
+ </tr>
@@ -0,0 +1,4 @@
1
+ <span class="periodic-table-keep-state hidden">false</span>
2
+ <table class="periodic-table periodic-table-simple">
3
+ {{periodic_table|safe}}
4
+ </table>
@@ -0,0 +1,14 @@
1
+ """ Url router for the periodic table module
2
+ """
3
+
4
+ from django.urls import re_path
5
+
6
+ from core_module_periodic_table_app.views import PeriodicTableModule
7
+
8
+ urlpatterns = [
9
+ re_path(
10
+ r"module-periodic-table",
11
+ PeriodicTableModule.as_view(),
12
+ name="core_module_periodic_table_view",
13
+ ),
14
+ ]
@@ -0,0 +1,63 @@
1
+ """ Periodic table module view
2
+ """
3
+
4
+ from core_parser_app.tools.modules.views.builtin.popup_module import (
5
+ AbstractPopupModule,
6
+ )
7
+ from core_parser_app.tools.modules.views.module import AbstractModule
8
+
9
+
10
+ class PeriodicTableModule(AbstractPopupModule):
11
+ """Periodic Table Module"""
12
+
13
+ def __init__(self):
14
+ AbstractPopupModule.__init__(
15
+ self,
16
+ button_label="Select Element",
17
+ styles=["core_module_periodic_table_app/css/periodic.css"],
18
+ scripts=["core_module_periodic_table_app/js/periodic.js"],
19
+ )
20
+
21
+ def _retrieve_data(self, request):
22
+ """Retrieve module's data
23
+
24
+ Args:
25
+ request:
26
+
27
+ Returns:
28
+
29
+ """
30
+ data = ""
31
+ if request.method == "GET":
32
+ if "data" in request.GET:
33
+ data = request.GET["data"]
34
+ elif request.method == "POST":
35
+ if "selectedElement" in request.POST:
36
+ data = request.POST["selectedElement"]
37
+ return data
38
+
39
+ def _render_data(self, request):
40
+ """Return module's data rendering
41
+
42
+ Args:
43
+ request:
44
+
45
+ Returns:
46
+
47
+ """
48
+ if len(self.data) > 0:
49
+ return "Chosen element: " + self.data
50
+
51
+ return "No selected element."
52
+
53
+ def _get_popup_content(self):
54
+ """Return module's data rendering"""
55
+ selected_elements = [self.data]
56
+ template = AbstractModule.render_template(
57
+ "core_module_periodic_table_app/periodic.html",
58
+ {"selected_elements": selected_elements},
59
+ )
60
+ return AbstractModule.render_template(
61
+ "core_module_periodic_table_app/periodic_simple.html",
62
+ {"periodic_table": template},
63
+ )
@@ -0,0 +1,33 @@
1
+ Metadata-Version: 2.1
2
+ Name: core-module-periodic-table-app
3
+ Version: 2.18.0
4
+ Summary: Periodic table module for the parser core project
5
+ Home-page: https://github.com/usnistgov/core_module_periodic_table_app
6
+ Author: NIST IT Lab
7
+ Author-email: itl_inquiries@nist.gov
8
+ License-File: LICENSE.md
9
+
10
+ core_module_periodic_table_app
11
+ ==============================
12
+
13
+ Periodic Table module for the parser core project.
14
+
15
+ Quick start
16
+ ===========
17
+
18
+ 1. Add "core_module_periodic_table_app" to your INSTALLED_APPS setting
19
+ ----------------------------------------------------------------------
20
+
21
+ .. code:: python
22
+
23
+ INSTALLED_APPS = [
24
+ ...
25
+ 'core_module_periodic_table_app',
26
+ ]
27
+
28
+ 2. Include the core_module_periodic_table_app URLconf in your project urls.py
29
+ -----------------------------------------------------------------------------
30
+
31
+ .. code:: python
32
+
33
+ url(r'^', include('core_module_periodic_table_app.urls')),
@@ -0,0 +1,22 @@
1
+ LICENSE.md
2
+ MANIFEST.in
3
+ README.rst
4
+ pyproject.toml
5
+ requirements.core.txt
6
+ requirements.txt
7
+ setup.py
8
+ core_module_periodic_table_app/__init__.py
9
+ core_module_periodic_table_app/urls.py
10
+ core_module_periodic_table_app/views.py
11
+ core_module_periodic_table_app.egg-info/PKG-INFO
12
+ core_module_periodic_table_app.egg-info/SOURCES.txt
13
+ core_module_periodic_table_app.egg-info/dependency_links.txt
14
+ core_module_periodic_table_app.egg-info/requires.txt
15
+ core_module_periodic_table_app.egg-info/top_level.txt
16
+ core_module_periodic_table_app/static/core_module_periodic_table_app/css/periodic.css
17
+ core_module_periodic_table_app/static/core_module_periodic_table_app/js/periodic.js
18
+ core_module_periodic_table_app/templates/core_module_periodic_table_app/periodic.html
19
+ core_module_periodic_table_app/templates/core_module_periodic_table_app/periodic_simple.html
20
+ tests/__init__.py
21
+ tests/test_settings.py
22
+ tests/test_unit_views.py
@@ -0,0 +1,2 @@
1
+ Django
2
+ core-parser-app==2.18.*
@@ -0,0 +1,2 @@
1
+ core_module_periodic_table_app
2
+ tests
@@ -0,0 +1,5 @@
1
+ [tool.black]
2
+ line-length = 79
3
+ target-version = ['py36']
4
+ include = '\.pyi?$'
5
+
@@ -0,0 +1 @@
1
+ core-parser-app==2.18.*
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ """ Setup core module periodic table app
2
+ """
3
+
4
+ from os import chdir, pardir
5
+ from os.path import join, exists, dirname, normpath, abspath
6
+
7
+ from setuptools import find_packages, setup
8
+
9
+ reqs_default = join(dirname(__file__), "requirements.txt")
10
+ reqs_core = join(dirname(__file__), "requirements.core.txt")
11
+ required = []
12
+
13
+ if exists(reqs_default):
14
+ with open(reqs_default) as f:
15
+ required += f.read().splitlines()
16
+
17
+ if exists(reqs_core):
18
+ with open(reqs_core) as f:
19
+ required += f.read().splitlines()
20
+
21
+ with open(join(dirname(__file__), "README.rst")) as f:
22
+ long_desc = f.read()
23
+
24
+ # Allow setup.py to be run from any path
25
+ chdir(normpath(join(abspath(__file__), pardir)))
26
+
27
+ setup(
28
+ name="core_module_periodic_table_app",
29
+ version="2.18.0",
30
+ description="Periodic table module for the parser core project",
31
+ long_description=long_desc,
32
+ author="NIST IT Lab",
33
+ author_email="itl_inquiries@nist.gov",
34
+ url="https://github.com/usnistgov/core_module_periodic_table_app",
35
+ packages=find_packages(),
36
+ include_package_data=True,
37
+ install_requires=required,
38
+ )
@@ -0,0 +1,46 @@
1
+ """ Test settings
2
+ """
3
+
4
+ SECRET_KEY = "fake-key"
5
+
6
+ INSTALLED_APPS = [
7
+ # Django apps
8
+ "django.contrib.admin",
9
+ "django.contrib.auth",
10
+ "django.contrib.contenttypes",
11
+ "django.contrib.sessions",
12
+ "django.contrib.messages",
13
+ "django.contrib.sites",
14
+ # Local apps
15
+ "core_main_app",
16
+ "core_parser_app",
17
+ "core_module_periodic_table_app",
18
+ "tests",
19
+ ]
20
+
21
+
22
+ MIDDLEWARE = (
23
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
24
+ "django.contrib.messages.middleware.MessageMiddleware",
25
+ "django.contrib.sessions.middleware.SessionMiddleware",
26
+ )
27
+
28
+ TEMPLATES = [
29
+ {
30
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
31
+ "DIRS": ["templates"],
32
+ "APP_DIRS": True,
33
+ "OPTIONS": {
34
+ "context_processors": [
35
+ "django.template.context_processors.debug",
36
+ "django.template.context_processors.request",
37
+ "django.contrib.auth.context_processors.auth",
38
+ "django.contrib.messages.context_processors.messages",
39
+ "django.template.context_processors.i18n",
40
+ ],
41
+ },
42
+ },
43
+ ]
44
+ CELERYBEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
45
+ MONGODB_INDEXING = False
46
+ MONGODB_ASYNC_SAVE = False
@@ -0,0 +1,125 @@
1
+ """ Module periodic table testing
2
+ """
3
+
4
+ from unittest.case import TestCase
5
+
6
+ from django.http.request import HttpRequest
7
+ from unittest.mock import patch
8
+
9
+ from core_module_periodic_table_app.views import PeriodicTableModule
10
+
11
+
12
+ class TestPeriodicTableModuleRetrieveData(TestCase):
13
+ """Test Periodic Table Module Retrieve Data"""
14
+
15
+ @patch(
16
+ "core_parser_app.tools.modules.views.module.AbstractModule.render_template"
17
+ )
18
+ def test_periodic_table_module_retrieve_data_returns_element_if_data_given(
19
+ self, render_template
20
+ ):
21
+ """test_periodic_table_module_retrieve_data_returns_element_if_data_given"""
22
+
23
+ # Arrange
24
+ request = HttpRequest()
25
+ element = "AC"
26
+ request.method = "GET"
27
+ request.GET = {
28
+ "data": element,
29
+ }
30
+ my_module = PeriodicTableModule()
31
+ # Act
32
+ result = my_module._retrieve_data(request)
33
+ self.assertEqual(True, result == element)
34
+
35
+ @patch(
36
+ "core_parser_app.tools.modules.views.module.AbstractModule.render_template"
37
+ )
38
+ def test_periodic_table_module_retrieve_data_returns_empty_if_no_data_given(
39
+ self, render_template
40
+ ):
41
+ """test_periodic_table_module_retrieve_data_returns_empty_if_no_data_given"""
42
+
43
+ # Arrange
44
+ request = HttpRequest()
45
+ request.method = "GET"
46
+ request.GET = {}
47
+ my_module = PeriodicTableModule()
48
+ # Act
49
+ result = my_module._retrieve_data(request)
50
+ self.assertEqual(True, result == "")
51
+
52
+ @patch(
53
+ "core_parser_app.tools.modules.views.module.AbstractModule.render_template"
54
+ )
55
+ def test_periodic_table_module_retrieve_data_returns_element_if_selected_data_given(
56
+ self, render_template
57
+ ):
58
+ """test_periodic_table_module_retrieve_data_returns_element_if_selected_data_given"""
59
+
60
+ # Arrange
61
+ request = HttpRequest()
62
+ element = "AC"
63
+ request.method = "POST"
64
+ request.POST = {
65
+ "selectedElement": element,
66
+ }
67
+ my_module = PeriodicTableModule()
68
+ # Act
69
+ result = my_module._retrieve_data(request)
70
+ self.assertEqual(True, result == element)
71
+
72
+ @patch(
73
+ "core_parser_app.tools.modules.views.module.AbstractModule.render_template"
74
+ )
75
+ def test_periodic_table_module_retrieve_data_returns_empty_if_no_selected_data_given(
76
+ self, render_template
77
+ ):
78
+ """test_periodic_table_module_retrieve_data_returns_empty_if_no_selected_data_given"""
79
+
80
+ # Arrange
81
+ request = HttpRequest()
82
+ request.method = "POST"
83
+ request.POST = {}
84
+ my_module = PeriodicTableModule()
85
+ # Act
86
+ result = my_module._retrieve_data(request)
87
+ self.assertEqual(True, result == "")
88
+
89
+
90
+ class TestPeriodicTableModuleRenderData(TestCase):
91
+ """Test Periodic Table Module Render Data"""
92
+
93
+ @patch(
94
+ "core_parser_app.tools.modules.views.module.AbstractModule.render_template"
95
+ )
96
+ def test_periodic_table_module_render_data_returns_the_chosen_element_if_given(
97
+ self, render_template
98
+ ):
99
+ """test_periodic_table_module_render_data_returns_the_chosen_element_if_given"""
100
+
101
+ # Arrange
102
+ request = HttpRequest()
103
+ element = "AC"
104
+ my_module = PeriodicTableModule()
105
+ my_module.data = element
106
+ # Act
107
+ result = my_module._render_data(request)
108
+ self.assertEqual(True, result == "Chosen element: " + element)
109
+
110
+ @patch(
111
+ "core_parser_app.tools.modules.views.module.AbstractModule.render_template"
112
+ )
113
+ def test_periodic_table_module_render_data_returns_no_selected_element_if_not_given(
114
+ self, render_template
115
+ ):
116
+ """test_periodic_table_module_render_data_returns_no_selected_element_if_not_given"""
117
+
118
+ # Arrange
119
+ request = HttpRequest()
120
+ element = ""
121
+ my_module = PeriodicTableModule()
122
+ my_module.data = element
123
+ # Act
124
+ result = my_module._render_data(request)
125
+ self.assertEqual(True, result == "No selected element.")