Skip to content

Commit

Permalink
Merge pull request #9 from educorvi/development2
Browse files Browse the repository at this point in the history
Development2
  • Loading branch information
seppowalther authored Dec 8, 2021
2 parents 018b89c + 3c034d2 commit 92e7682
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 44 deletions.
31 changes: 11 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,25 @@
edi.substanceforms
==================

Tell me what your product does
The Add-On edi.substanceforms has been developed for the free Open Source Web Content Management System Plone.

Features
--------

- Can be bullet points


Examples
--------

This add-on can be seen in action at the following sites:
- Is there a page on the internet where everybody can see the features?
- employees in the printing and paper processing industry can search for chemical products used in the manufacturing process with the least impact on human health
- they can manage, create, update and delete those substances and substance mixtures


Documentation
-------------

Full documentation for end users can be found in the "docs" folder, and is also available online at http://docs.plone.org/foo/bar
The full documentation of this project can be found online here: https://substanceforms.educorvi.de


Translations
------------

This product has been translated into

- Klingon (thanks, K'Plai)

This product and the full documentation is written in German.

Installation
------------
Expand All @@ -54,19 +45,19 @@ and then running ``bin/buildout``
Contribute
----------

- Issue Tracker: https://github.com/collective/edi.substanceforms/issues
- Source Code: https://github.com/collective/edi.substanceforms
- Documentation: https://docs.plone.org/foo/bar
- Issue Tracker: https://github.com/educorvi/edi.substanceforms/issues
- Source Code: https://github.com/educorvi/edi.substanceforms
- Documentation: https://substanceforms.educorvi.de


Support
-------

If you are having issues, please let us know.
We have a mailing list located at: project@example.com
If you are having issues, please let me know.
Feel free to contact me here: seppo.walther@educorvi.de


License
-------

The project is licensed under the GPLv2.
The project is licensed under the MIT License.
8 changes: 8 additions & 0 deletions src/edi/substanceforms/views/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
permission="zope2.View"
/>

<browser:page
name="delete-synonyms-form"
for="edi.substanceforms.content.tabelle.ITabelle"
class=".create_substance_form.DeleteSynonymsFormView"
template = "create_view.pt"
permission="zope2.View"
/>

<browser:page
name="update-manufacturer-form"
for="edi.substanceforms.content.tabelle.ITabelle"
Expand Down
48 changes: 45 additions & 3 deletions src/edi/substanceforms/views/create_substance_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class SynonymForm(Form):
synonym_name = StringField("Synonyn", [validators.required()], render_kw={'class': 'form-control'})
item_id = HiddenField()

class DeleteSynonymsForm(Form):
sure = BooleanField("Synonyme löschen", render_kw={'class': 'form-check-input'})
item_id = HiddenField()

class CreateFormView(WTFormView):
formClass = CreateForm
buttons = ('Speichern', 'Abbrechen')
Expand Down Expand Up @@ -260,7 +264,6 @@ def __call__(self):
self.db.close()
return self.index()


def renderForm(self):
self.form.item_id.default=self.itemid
self.form.process()
Expand All @@ -269,12 +272,51 @@ def renderForm(self):
def submit(self, button):
"""
"""
redirect_url = self.context.aq_parent.absolute_url()
#redirect_url = self.context.aq_parent.absolute_url()
redirect_url = self.context.absolute_url() + '/single_view?item=' + self.form.item_id.data
if button == 'Speichern': #and self.validate():
insert = "INSERT INTO synonyms VALUES (DEFAULT, %s, '%s');" % (self.form.item_id.data,
self.form.synonym_name.data)
self.db.execute(insert)
message = u'Der Reinstoff wurde erfolgreich gelöscht'
message = u'Das Synonym wurde erfolgreich angelegt'
ploneapi.portal.show_message(message=message, type='info', request=self.request)

self.db.close()
return self.request.response.redirect(redirect_url)

elif button == 'Abbrechen':
return self.request.response.redirect(redirect_url)

class DeleteSynonymsFormView(CreateFormView):
formClass = DeleteSynonymsForm

def __call__(self):
dbdata = self.context.aq_parent
self.db = DBConnect(host=dbdata.host, db=dbdata.database, user=dbdata.username, password=dbdata.password)
if self.submitted:
button = self.hasButtonSubmitted()
if button:
result = self.submit(button)
if result:
return result
self.itemid = self.request.get('itemid')
self.db.close()
return self.index()

def renderForm(self):
self.form.item_id.default=self.itemid
self.form.process()
return self.formTemplate()

def submit(self, button):
"""
"""
#redirect_url = self.context.aq_parent.absolute_url()
redirect_url = self.context.absolute_url() + '/single_view?item=' + self.form.item_id.data
if button == 'Speichern': #and self.validate():
insert = "DELETE FROM synonyms WHERE substance_id = %s;" % self.form.item_id.data
self.db.execute(insert)
message = u'Die Synonyme wurden erfolgreich gelöscht'
ploneapi.portal.show_message(message=message, type='info', request=self.request)

self.db.close()
Expand Down
4 changes: 2 additions & 2 deletions src/edi/substanceforms/views/substance_mixture_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
</thead>
<tbody>
<tr>
<td tal:condition="python: view.get_attr_translation('substance_types', article[5])">Typ des Wasch- und Reinigungsmittels</td>
<td tal:condition="python: view.get_attr_translation('substance_types', article[5])" tal:content="python: view.get_attr_translation('substance_types', article[5])"/>
<td tal:condition="python: view.get_attr_translation('substance_types_new', article[5])">Typ des Wasch- und Reinigungsmittels</td>
<td tal:condition="python: view.get_attr_translation('substance_types_new', article[5])" tal:content="python: view.get_attr_translation('substance_types_new', article[5])"/>
</tr>
<tr>
<td tal:condition="python: view.get_attr_translation('branchen', article[4])">Branche</td>
Expand Down
40 changes: 22 additions & 18 deletions src/edi/substanceforms/views/substance_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,40 @@
</thead>
<tbody>
<tr>
<td>Name</td>
<td tal:content="python:article[1]"/>
<td tal:condition="python:article[1]">Name</td>
<td tal:condition="python:article[1]" tal:content="python:article[1]"/>
</tr>
<tr>
<td>Synonyme</td>
<td tal:content="python:view.translate_synonyms(view.get_synonyms())"/>
<td tal:condition="python:view.translate_synonyms(view.get_synonyms())">Synonyme</td>
<td tal:condition="python:view.translate_synonyms(view.get_synonyms())" tal:content="python:view.translate_synonyms(view.get_synonyms())"/>
</tr>
<tr>
<td>Beschreibung</td>
<td tal:content="python:article[2]"/>
<td tal:condition="python:article[2]">Beschreibung</td>
<td tal:condition="python:article[2]" tal:content="python:article[2]"/>
</tr>
<tr>
<td>CAS-Nummer</td>
<td tal:content="python:article[4]"/>
<td tal:condition="python:article[4]">CAS-Nummer</td>
<td tal:condition="python:article[4]" tal:content="python:article[4]"/>
</tr>
<tr>
<td>EG-Nummer</td>
<td tal:content="python:article[5]"/>
<td tal:condition="python:article[5]">EG-Nummer</td>
<td tal:condition="python:article[5]" tal:content="python:article[5]"/>
</tr>
<tr>
<td>Hautschutzmittelgruppe</td>
<td tal:content="python: view.get_attr_translation('hskategorie', article[8])"/>
<td tal:condition="python: view.get_attr_translation('hskategorie', article[8])">Hautschutzmittelgruppe</td>
<td tal:condition="python: view.get_attr_translation('hskategorie', article[8])" tal:content="python: view.get_attr_translation('hskategorie', article[8])"/>
</tr>
<tr>
<td>Brache</td>
<td tal:content="python: view.get_attr_translation('branchen', article[9])"/>
<td tal:condition="python: view.get_attr_translation('branchen', article[9])">Brache</td>
<td tal:condition="python: view.get_attr_translation('branchen', article[9])" tal:content="python: view.get_attr_translation('branchen', article[9])"/>
</tr>
<tr>
<td>DNEL Inhalation [mg/m3]: lokal</td>
<td tal:content="python:article[10]"/>
<td tal:condition="python:article[10]">DNEL Inhalation [mg/m3]: lokal</td>
<td tal:condition="python:article[10]" tal:content="python:article[10]"/>
</tr>
<tr>
<td>DNEL Inhalation [mg/m3]: systemisch</td>
<td tal:content="python:article[11]"/>
<td tal:condition="python:article[11]">DNEL Inhalation [mg/m3]: systemisch</td>
<td tal:condition="python:article[11]" tal:content="python:article[11]"/>
</tr>
</tbody>
</table>
Expand All @@ -97,6 +97,10 @@
<a class="btn btn-primary" tal:attributes="href python:context.absolute_url()+'/add-synonym-form?itemid=%s' % view.itemid" role="button">Synonym hinzufügen</a>
</section>

<section class="mt-3 mb-3" tal:condition="view/userCanEdit">
<a class="btn btn-primary" tal:attributes="href python:context.absolute_url()+'/delete-synonyms-form?itemid=%s' % view.itemid" role="button">Synonyme löschen</a>
</section>

</div>

<!-- Portlets -->
Expand Down
4 changes: 3 additions & 1 deletion src/edi/substanceforms/vocabularies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
hskategorie = [
(u"id_wasserloeslich", u"gegen wasserlösliche Arbeitsstoffe"),
(u"id_nichtwasserloeslich", u"gegen wasserunlösliche Arbeitsstoffe"),
(u"id_wechselnd", u"gegen wechselnde Arbeitsstoffe")
(u"id_wechselnd", u"gegen wechselnde Arbeitsstoffe"),
(u"alle_branchen", u"alle Branchen")
]

branchen = [
Expand Down Expand Up @@ -95,6 +96,7 @@
'hskategorie':hskategorie,
'branchen':branchen,
'substance_types':substance_types,
'substance_types_new':substance_types_new,
'produktkategorien':produktkategorien,
'produktklassen':produktklassen,
'classifications':classifications,
Expand Down

0 comments on commit 92e7682

Please sign in to comment.