Ejemplo n.º 1
0
    def __init__(self, health_center=None, parent=None):
        super(HealthCenterDialog, self).__init__(parent)

        self.success = False
        self.health_center = health_center
        self.setupUi(self)

        health_center_types = []
        for hct in session.query(HealthCenterType).order_by(HealthCenterType.name):
            health_center_types.append(QString(hct.name))
        self.typeComboBox.addItems(health_center_types)

        if self.health_center is not None:
            self.nameLineEdit.setText(QString(self.health_center.name))
            self.latitudeLineEdit.setText(QString(self.health_center.latitude))
            self.longitudeLineEdit.setText(
                    QString(self.health_center.longitude))
            self.descriptionTextEdit.setText(
                    QString(self.health_center.description))
            self.nameResponsibleLineEdit.setText(
                    QString(self.health_center.responsible_person))
            self.phoneNumberLineEdit.setText(
                    QString(self.health_center.phone_number))
            self.emailAddressLineEdit.setText(
                    QString(self.health_center.email_address))

        if not MAC:
            self.buttonBox.setFocusPolicy(Qt.NoFocus)

        self.connect(self.buttonBox.button(QDialogButtonBox.Ok),
                    SIGNAL('clicked()'), self.save)
        self.connect(self.buttonBox.button(QDialogButtonBox.Cancel),
                    SIGNAL('clicked()'), self.reject)
        self.connect(self, SIGNAL('rejected()'), self.reject)
Ejemplo n.º 2
0
    def save(self):
        if not self.isValid():
            return

        if self.rating_criteria is not None:
            session.query(RatingCriteria).filter(
                    RatingCriteria.id == self.rating_criteria.id).update(
                            values=dict(
                                name=self.name, min_value=self.min_value,
                                max_value=self.max_value,
                                description=self.description,
                                valid_from = self.valid_from
                                ))
        else:
            rc = RatingCriteria(self.name, self.min_value, self.max_value,
                    self.valid_from, self.description)
            session.add(rc)

        session.commit()
        self.success = True
        self.accept()
Ejemplo n.º 3
0
    def save(self):
        if not self.isValid():
            return

        if self.health_center is not None:
            session.query(HealthCenter).filter(
                    HealthCenter.id == self.health_center.id).update(
                            values=dict(
                            name=self.name, type_id=self.type_id,
                            latitude=self.latitude, longitude=self.longitude,
                            description=self.description,
                            responsible_person=self.responsible_person,
                            phone_number=self.phone_number,
                            email_address=self.email_address
                            ))
        else:
            hc = HealthCenter(self.name, self.type_id, self.latitude,
                    self.longitude, self.responsible_person, self.phone_number,
                    self.email_address, self.description)
            session.add(hc)

        session.commit()
        self.success = True
        self.accept()
Ejemplo n.º 4
0
    def isValid(self):

        self.name = unicode(self.nameLineEdit.text())
        if self.name == '':
            QMessageBox.warning(self, 'Errors in form', 'Name can\'t be empty.')
            self.nameLineEdit.setFocus()
            return False

        self.type_id = session.query(HealthCenterType).filter_by(
                name=unicode(self.typeComboBox.currentText())).one().id

        self.latitude = unicode(self.latitudeLineEdit.text())
        try:
            float(self.latitude)
        except:
            QMessageBox.warning(self, 'Errors in form',
                    'Latitude should be numeric.')
            self.latitudeLineEdit.setFocus()
            return False

        self.longitude = unicode(self.longitudeLineEdit.text())
        try:
            float(self.longitude)
        except:
            QMessageBox.warning(self, 'Errors in form',
                    'Longitude should be numeric.')
            self.longitudeLineEdit.setFocus()
            return False

        self.description = unicode(self.descriptionTextEdit.toPlainText())

        self.responsible_person = unicode(self.nameResponsibleLineEdit.text())
        if self.responsible_person == '':
            QMessageBox.warning(self, 'Errors in form',
                    'Name of Responsible Person can\'t be empty.')
            self.nameResponsibleLineEdit.setFocus()
            return False

        self.phone_number = unicode(self.phoneNumberLineEdit.text())
        if self.phone_number == '':
            QMessageBox.warning(self, 'Errors in form',
                    'Phone Number can\'t be empty.')
            self.phoneNumberLineEdit.setFocus()
            return False

        self.email_address = unicode(self.emailAddressLineEdit.text())

        return True
Ejemplo n.º 5
0
Archivo: main.py Proyecto: psjinx/gdmt
def getRatingCriterias():
    rc_list = []
    for rc in session.query(RatingCriteria).order_by(RatingCriteria.name):
        rc_list.append(rc)
    return rc_list
Ejemplo n.º 6
0
Archivo: main.py Proyecto: psjinx/gdmt
def getHealthCenters():
    hc_list = []
    for hc in session.query(HealthCenter).order_by(HealthCenter.name):
        hc_list.append(hc)
    return hc_list