Пример #1
0
    def submit(self, button):
        redirect_url = self.context.aq_parent.absolute_url()
        if button == 'Speichern': #and self.validate():

            if True:
                conn = psycopg2.connect(host=self.host, user=self.username, dbname=self.dbname, password=self.password)
                cur = conn.cursor()
                insert = """INSERT INTO printing_machine VALUES (DEFAULT, '%s', '%s', '%s', 
                            %s, %s);""" % (self.form.title.data, 
                                           self.form.description.data,
                                           self.context.aq_parent.get_webcode(),
                                           check_value(self.form.image.data),
                                           check_value(self.form.manufacturer_id.data))
          
                cur.execute(insert)
                conn.commit()
                cur.close()
                conn.close()
                message=u'Die Maschine wurde erfolgreich gespeichert.'
                ploneapi.portal.show_message(message=message, type='info', request=self.request)
            #except:
            #    print(u'Fehler beim Einfügen in die Datenbank')
            return self.request.response.redirect(redirect_url)

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
Пример #2
0
    def submit(self, button):
        """
        """
        redirect_url = self.context.absolute_url(
        ) + '/single_view?item=' + self.form.item_id.data
        if button == 'Speichern':  #and self.validate():
            command = """UPDATE spray_powder SET title='%s', description='%s', product_class='%s', starting_material='%s',
                         median_value=%s, volume_share=%s, checked_emissions=%s
                         WHERE spray_powder_id = %s;""" % (
                self.form.title.data, self.form.description.data,
                self.form.product_class.data, self.form.starting_material.data,
                check_value(self.form.median_value.data),
                check_value(self.form.volume_share.data),
                check_value(
                    self.form.checked_emissions.data), self.form.item_id.data)
            self.db.execute(command)
            message = u'Der Druckbestäubungspuder wurde erfolgreich aktualisiert.'
            ploneapi.portal.show_message(message=message,
                                         type='info',
                                         request=self.request)
            #message = u'Fehler beim Aktualisieren des Gefahrstoffgemisches'
            #ploneapi.portal.show_message(message=message, type='error', request=self.request)

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

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
Пример #3
0
    def submit(self, button):
        """
        """
        redirect_url = self.context.aq_parent.absolute_url()
        if button == 'Speichern':  #and self.validate():
            command = """UPDATE substance SET title='%s', description='%s', casnr=%s, egnr=%s, concentration=%s,
                         skin_category='%s', branch='%s', formula='%s', mol='%s', link='%s'
                         WHERE substance_id = %s;""" % (
                self.form.title.data, self.form.description.data,
                check_value(
                    self.form.casnr.data), check_value(self.form.egnr.data),
                check_value(self.form.concentration.data),
                self.form.skin_category.data, self.form.branch.data,
                self.form.formula.data, self.form.mol.data,
                self.form.gestislink.data, self.form.item_id.data)
            self.db.execute(command)
            message = u'Der Reinstoff wurde erfolgreich aktualisiert.'
            ploneapi.portal.show_message(message=message,
                                         type='info',
                                         request=self.request)
            #message = u'Fehler beim Aktualisieren des Gefahrstoffgemisches'
            #ploneapi.portal.show_message(message=message, type='error', request=self.request)

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

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
Пример #4
0
    def submit(self, button):
        """
        image_url = ''
        if self.form.image_url.data.filename:
            image_url = self.create_image(self.form.image_url, self.form.title.data)
        """
        redirect_url = self.context.aq_parent.absolute_url()
        if button == 'Speichern':  #and self.validate():
            conn = psycopg2.connect(host=self.host,
                                    user=self.username,
                                    dbname=self.dbname,
                                    password=self.password)
            cur = conn.cursor()
            insert = """INSERT INTO substance (title, description, webcode, casnr, egnr, concentration, skin_category, branch, formula, mol, link, status)
            VALUES ('%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s);""" % (
                self.form.title.data,
                self.form.description.data,
                self.context.aq_parent.get_webcode(),
                check_value(self.form.casnr.data),
                check_value(self.form.egnr.data),
                check_value(self.form.concentration.data),
                check_value(self.form.skin_category.data),
                check_value(self.form.branch.data),
                check_value(self.form.formula.data),
                check_value(self.form.mol.data),
                check_value(self.form.gestislink.data),
                check_value(self.form.status),
            )

            cur.execute(insert)
            conn.commit()
            cur.close()
            conn.close()

            message = u'Das Wasch- und Reinigungsmittel wurde erfolgreich gespeichert.'
            ploneapi.portal.show_message(message=message,
                                         type='info',
                                         request=self.request)

            return self.request.response.redirect(redirect_url)

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
Пример #5
0
    def submit(self, button):
        image_url = ''
        if self.form.image_url.data.filename:
            image_url = self.create_image(self.form.image_url,
                                          self.form.title.data)
        redirect_url = self.context.aq_parent.absolute_url()
        if button == 'Speichern':  #and self.validate():
            insert = """INSERT INTO spray_powder VALUES (DEFAULT, '%s', '%s', '%s',
                        %s, %s, %s, %s, %s, %s, %s, %s);""" % (
                self.form.title.data, self.form.description.data,
                self.context.aq_parent.get_webcode(),
                check_value(self.form.product_class.data),
                check_value(self.form.starting_material.data),
                check_value(self.form.median_value.data),
                check_value(self.form.volume_share.data),
                check_value(self.form.checked_emissions.data),
                check_value(self.form.date_checked.data),
                check_value(image_url), self.form.manufacturer_id.data)

            if self.form.image_url.data.filename:

                try:
                    self.db.execute(insert)
                    message = u'Das Wasch- und Reinigungsmittel wurde erfolgreich gespeichert.'
                    ploneapi.portal.show_message(message=message,
                                                 type='info',
                                                 request=self.request)
                except:
                    imageobj = ploneapi.content.get(UID=image_url)
                    ploneapi.content.delete(imageobj)

                    message = u'Fehler beim Hinzufügen des Gefahrstoffgemisches'
                    ploneapi.portal.show_message(message=message,
                                                 type='error',
                                                 request=self.request)

                self.db.close()

            else:
                self.db.execute(insert)
                self.db.close()

                message = u'Das Wasch- und Reinigungsmittel wurde erfolgreich gespeichert.'
                ploneapi.portal.show_message(message=message,
                                             type='info',
                                             request=self.request)

            return self.request.response.redirect(redirect_url)

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
    def submit(self, button):
        redirect_url = self.context.aq_parent.absolute_url()
        if button == 'Speichern' and self.validate():

            if True:
                insert = """INSERT INTO manufacturer VALUES (DEFAULT, '%s', '%s', '%s', %s);""" % (
                    self.form.title.data, self.form.description.data,
                    self.context.aq_parent.get_webcode(),
                    check_value(self.form.homepage.data))
                self.db.execute(insert)
                self.db.close()
                message = u'Der Hersteller wurde erfolgreich gespeichert.'
                ploneapi.portal.show_message(message=message,
                                             type='info',
                                             request=self.request)
            #except:
            #    print(u'Fehler beim Einfügen in die Datenbank')
            return self.request.response.redirect(redirect_url)

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
Пример #7
0
    def submit(self, button):
        """
        """
        redirect_url = self.context.absolute_url(
        ) + '/single_view?item=' + self.form.item_id.data
        if button == 'Speichern':  #and self.validate():
            command = """UPDATE substance_mixture SET title=%s, description=%s, branch=%s, substance_type=%s,
                         evaporation_lane_150=%s, evaporation_lane_160=%s, evaporation_lane_170=%s, evaporation_lane_180=%s,
                         ueg=%s, response=%s, skin_category=%s, checked_emissions=%s,
                         flashpoint=%s, values_range=%s, comments=%s, productclass=%s
                         WHERE substance_mixture_id = %s;""" % \
                                                        (check_value(self.form.title.data),
                                                        check_value(self.form.description.data),
                                                        check_value(self.form.branch.data),
                                                        check_value(self.form.substance_type.data),
                                                        check_value(self.form.evaporation_lane_150.data),
                                                        check_value(self.form.evaporation_lane_160.data),
                                                        check_value(self.form.evaporation_lane_170.data),
                                                        check_value(self.form.evaporation_lane_180.data),
                                                        check_value(self.form.ueg.data),
                                                        check_value(self.form.response.data),
                                                        check_value(self.form.skin_category.data),
                                                        check_value(self.form.checked_emissions.data),
                                                        check_value(self.form.flashpoint.data),
                                                        check_value(self.form.values_range.data),
                                                        check_value(self.form.comments.data),
                                                        check_value(self.form.productclass.data),
                                                        check_value(self.form.item_id.data))
            self.db.execute(command)
            """

            neueliste = list()
            neuevocab = list()
            resultlist = list()
            listtoadd = list()
            vocabulary = get_vocabulary('application_areas')
            for n in vocabulary:
                neuevocab.append(n[0])
            for i in self.form.application_areas.data:
                getfromvocab = "SELECT DISTINCT mixture_id, area_id FROM areapairs, application_areas WHERE mixture_id = %s" % self.form.item_id.data
                currentareas = self.db.execute(getfromvocab)
                for v in currentareas:
                    command = "SELECT application_area_name FROM application_areas WHERE application_area_id = %s" % v[1]
                    result = self.db.execute(command)
                    result = result[0][0]
                    resultlist.append(result)
                for m in neuevocab:
                    #import pdb; pdb.set_trace()
                    for l in resultlist:
                        if i == l and i not in neueliste:
                            neueliste.append(i)

                if i not in neueliste:
                    idcommand = "SELECT application_area_id FROM application_areas WHERE application_area_name = 'Reiniger_Leitstaende_Sensoren'"
                    richtigeid = self.db.execute(idcommand)
                    insertcommand = "INSERT INTO areapairs (area_id, mixture_id) VALUES (%s, %s);" % (richtigeid[0][0],
                                                                                                   self.form.item_id.data)
                    self.db.execute(insertcommand)

            print(neueliste)
            print(listtoadd)

                #del newlist[::2]
                #import pdb; pdb.set_trace()

        """

            deletecommand = "DELETE FROM areapairs WHERE mixture_id = %s" % self.form.item_id.data
            self.db.execute(deletecommand)
            for i in self.form.application_areas.data:
                insertcommand = "INSERT INTO areapairs (area_id, mixture_id) VALUES (%s, %s)" % (
                    int(i), self.form.item_id.data)
                self.db.execute(insertcommand)

            deletecommand2 = "DELETE FROM usecasepairs WHERE mixture_id = %s" % self.form.item_id.data
            self.db.execute(deletecommand2)
            for i in self.form.usecases.data:
                insertcommand2 = "INSERT INTO usecasepairs (usecase_id, mixture_id) VALUES (%s, %s)" % (
                    int(i), self.form.item_id.data)
                self.db.execute(insertcommand2)

            message = u'Das Gefahrstoffgemisch wurde erfolgreich aktualisiert.'
            ploneapi.portal.show_message(message=message,
                                         type='info',
                                         request=self.request)
            #message = u'Fehler beim Aktualisieren des Gefahrstoffgemisches'
            #ploneapi.portal.show_message(message=message, type='error', request=self.request)

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

        elif button == 'Abbrechen':
            return self.request.response.redirect(redirect_url)
Пример #8
0
    def submit(self, button):
        image_url = ''
        if self.form.image_url.data.filename:
            image_url = self.create_image(self.form.image_url,
                                          self.form.title.data)
        redirect_url = self.context.aq_parent.absolute_url()
        if button == 'Speichern':  #and self.validate():

            conn = psycopg2.connect(host=self.host,
                                    user=self.username,
                                    dbname=self.dbname,
                                    password=self.password)
            cur = conn.cursor()
            insert = """INSERT INTO substance_mixture (title, description, webcode, branch, substance_type,
                                                        evaporation_lane_150, evaporation_lane_160,
                                                        evaporation_lane_170, evaporation_lane_180, ueg, response,
                                                        skin_category, checked_emissions, date_checked, flashpoint,
                                                        values_range, comments, image_url, manufacturer_id)
                                                        VALUES ('%s', '%s', '%s', %s, '%s',
                                                        %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
                                                        %s, %s);""" \
                                                        % (self.form.title.data,
                                                        self.form.description.data,
                                                        self.context.aq_parent.get_webcode(),
                                                        check_value(self.form.branch.data),
                                                        self.form.substance_type.data,
                                                        check_value(self.form.evaporation_lane_150.data),
                                                        check_value(self.form.evaporation_lane_160.data),
                                                        check_value(self.form.evaporation_lane_170.data),
                                                        check_value(self.form.evaporation_lane_180.data),
                                                        check_value(self.form.ueg.data),
                                                        check_value(self.form.response.data),
                                                        check_value(self.form.skin_category.data),
                                                        self.form.checked_emissions.data,
                                                        check_value(self.form.date_checked.data),
                                                        check_value(self.form.flashpoint.data),
                                                        self.form.values_range.data,
                                                        check_value(self.form.comments.data),
                                                        check_value(image_url),
                                                        check_value(self.form.manufacturer_id.data.split('ID:')[-1]))

            areaids = list()
            for i in self.form.application_areas.data:
                selectcommand = "SELECT substance_mixture_id FROM substance_mixture ORDER BY substance_mixture_id DESC LIMIT 1"
                selectedid = self.db.execute(selectcommand)
                areaids.append([int(i), (int(selectedid[0][0])) + 1])

            caseids = list()
            for i in self.form.usecases.data:
                selectcommand = "SELECT substance_mixture_id FROM substance_mixture ORDER BY substance_mixture_id DESC LIMIT 1"
                selectedid = self.db.execute(selectcommand)
                caseids.append([int(i), (int(selectedid[0][0])) + 1])

            if self.form.image_url.data.filename:

                try:
                    self.db.execute(insert)
                    for i in areaids:
                        insertcommand = "INSERT INTO areapairs (area_id, mixture_id) VALUES (%s, %s)" % (
                            i[0], i[1])
                        self.db.execute(insertcommand)
                    for i in caseids:
                        insertcommand = "INSERT INTO usecasepairs (usecase_id, mixture_id) VALUES (%s, %s)" % (
                            i[0], i[1])
                        self.db.execute(insertcommand)
                    message = u'Das Wasch- und Reinigungsmittel wurde erfolgreich gespeichert.'
                    ploneapi.portal.show_message(message=message,
                                                 type='info',
                                                 request=self.request)
                except:
                    imageobj = ploneapi.content.get(UID=image_url)
                    ploneapi.content.delete(imageobj)

                    message = u'Fehler beim Hinzufügen des Gefahrstoffgemisches'
                    ploneapi.portal.show_message(message=message,
                                                 type='error',
                                                 request=self.request)

                self.db.close()

            else:
                self.db.execute(insert)
                for i in areaids:
                    insertcommand = "INSERT INTO areapairs (area_id, mixture_id) VALUES (%s, %s)" % (
                        i[0], i[1])
                    self.db.execute(insertcommand)
                for i in caseids:
                    insertcommand = "INSERT INTO usecasepairs (usecase_id, mixture_id) VALUES (%s, %s)" % (
                        i[0], i[1])
                    self.db.execute(insertcommand)
                self.db.close()
                message = u'Das Wasch- und Reinigungsmittel wurde erfolgreich gespeichert.'
                ploneapi.portal.show_message(message=message,
                                             type='info',
                                             request=self.request)

            return self.request.response.redirect(redirect_url)

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