Example #1
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.setMinimumWidth(600)

        labelCardType = QLabel(_('Type of card'))
        self.comboCardType = QComboBox()
        labelCardType.setBuddy(self.comboCardType)
        self.comboCardType.addItem(_('Normal'))
        self.comboCardType.addItem(_('Club'))

        labelFinish = QLabel(_('Team expiress after'))
        self.comboDuration = QComboBox()
        labelFinish.setBuddy(self.comboDuration)
        self.comboDuration.addItem(_('3 months'))
        self.comboDuration.addItem(_('6 months'))
        self.comboDuration.addItem(_('9 months'))
        self.comboDuration.addItem(_('12 months'))
        self.comboDuration.setDisabled(True)

        groupLayout = QGridLayout()
        groupLayout.setColumnStretch(1, 1)
        groupLayout.setColumnMinimumWidth(1, 250)

        groupLayout.addWidget(labelCardType, 0, 0)
        groupLayout.addWidget(self.comboCardType, 0, 1)
        groupLayout.addWidget(labelFinish, 2, 0)
        groupLayout.addWidget(self.comboDuration, 2, 1)

        self.tree = TeamTree(self)

        teamLayout = QVBoxLayout()
        teamLayout.addWidget(self.tree)

        groupTeams = QGroupBox(_('Available teams'))
        groupTeams.setLayout(teamLayout)

        self.buttonAssign = QPushButton(_('Assign'))
        self.buttonCancel = QPushButton(_('Cancel'))

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.buttonAssign)
        buttonLayout.addWidget(self.buttonCancel)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(groupLayout)
        mainLayout.addWidget(groupTeams)
        mainLayout.addLayout(buttonLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle(_('Choose the team'))
        self.setSignals()
Example #2
0
    def __init__(self, mode='training', parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.mode = mode
        self.setMinimumWidth(600)

        labelDate = QLabel(self.tr('Date'))
        self.editDate = QDateEdit()
        labelDate.setBuddy(self.editDate)
        current = QDate.currentDate()
        self.editDate.setDate(current)
        self.editDate.setMinimumDate(current)

        labelTime = QLabel(self.tr('Time'))
        self.editTime = QTimeEdit()
        labelTime.setBuddy(self.editTime)
        current = QTime.currentTime()
        time = QTime(current.hour(), current.minute())
        self.editTime.setTime(time)

        labelRoom = QLabel(self.tr('Room'))
        self.comboRoom = QComboBox()
        labelRoom.setBuddy(self.comboRoom)

        groupLayout = QGridLayout()
        groupLayout.setColumnStretch(1, 1)
        groupLayout.setColumnMinimumWidth(1, 250)

        row = 0
        groupLayout.addWidget(labelDate, row, 0)
        groupLayout.addWidget(self.editDate, row, 1)
        row += 1
        groupLayout.addWidget(labelTime, row, 0)
        groupLayout.addWidget(self.editTime, row, 1)
        row += 1
        if self.mode == 'rent':
            labelDuration = QLabel(self.tr('Duration'))
            self.editDuration = QTimeEdit()
            labelDuration.setBuddy(self.editDuration)
            self.editDuration.setTime(QTime(1, 0))
            groupLayout.addWidget(labelDuration, row, 0)
            groupLayout.addWidget(self.editDuration, row, 1)
            row += 1

        groupLayout.addWidget(labelRoom, row, 0)
        groupLayout.addWidget(self.comboRoom, row, 1)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(groupLayout)

        if self.mode == 'training':
            self.tree = TeamTree(self)
            teamLayout = QVBoxLayout()
            teamLayout.addWidget(self.tree)
            groupTeams = QGroupBox(self.tr('Available teams'))
            groupTeams.setLayout(teamLayout)
            mainLayout.addWidget(groupTeams)

        self.buttonAssign = QPushButton(self.tr('Assign'))
        self.buttonCancel = QPushButton(self.tr('Cancel'))

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.buttonAssign)
        buttonLayout.addWidget(self.buttonCancel)

        if self.mode == 'rent':
            labels = QStringList([self.tr('Renter'), self.tr('Status'), self.tr('Title'),
                                  self.tr('Begin'), self.tr('End')])

            self.rent = QTableWidget(0, 5)
            self.rent.setHorizontalHeaderLabels(labels)
            rentLayout = QVBoxLayout()
            rentLayout.addWidget(self.rent)
            rentGroup = QGroupBox(self.tr('Rents'))
            rentGroup.setLayout(rentLayout)
            mainLayout.addWidget(rentGroup)

            ajax = HttpAjax(self, '/manager/get_rents/', {}, self.parent.session_id)
            response = ajax.parse_json()
            self.rent_list = response['rent_list']
            status_desc = ( self.tr('Reserved'),
                            self.tr('Paid partially'),
                            self.tr('Paid') )
            if len(self.rent_list) == 0:
                self.buttonAssign.setDisabled(True)
            for row in self.rent_list:
                lastRow = self.rent.rowCount()
                self.rent.insertRow(lastRow)

                renter = '%s %s' % (row['renter']['last_name'],
                                    row['renter']['first_name'])
                status = [self.tr('Reserved'), self.tr('Paid partially'), self.tr('Paid')][int( row['status'] )]

                self.rent.setItem(lastRow, 0, QTableWidgetItem(renter))
                self.rent.setItem(lastRow, 1, QTableWidgetItem(status))
                self.rent.setItem(lastRow, 2, QTableWidgetItem(row['title']))
                self.rent.setItem(lastRow, 3, QTableWidgetItem(row['begin_date']))
                self.rent.setItem(lastRow, 4, QTableWidgetItem(row['end_date']))

        mainLayout.addLayout(buttonLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle(self.tr('Assign the event'))
        self.setSignals()
Example #3
0
class DlgEventAssign(QDialog):

    def __init__(self, mode='training', parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.mode = mode
        self.setMinimumWidth(600)

        labelDate = QLabel(self.tr('Date'))
        self.editDate = QDateEdit()
        labelDate.setBuddy(self.editDate)
        current = QDate.currentDate()
        self.editDate.setDate(current)
        self.editDate.setMinimumDate(current)

        labelTime = QLabel(self.tr('Time'))
        self.editTime = QTimeEdit()
        labelTime.setBuddy(self.editTime)
        current = QTime.currentTime()
        time = QTime(current.hour(), current.minute())
        self.editTime.setTime(time)

        labelRoom = QLabel(self.tr('Room'))
        self.comboRoom = QComboBox()
        labelRoom.setBuddy(self.comboRoom)

        groupLayout = QGridLayout()
        groupLayout.setColumnStretch(1, 1)
        groupLayout.setColumnMinimumWidth(1, 250)

        row = 0
        groupLayout.addWidget(labelDate, row, 0)
        groupLayout.addWidget(self.editDate, row, 1)
        row += 1
        groupLayout.addWidget(labelTime, row, 0)
        groupLayout.addWidget(self.editTime, row, 1)
        row += 1
        if self.mode == 'rent':
            labelDuration = QLabel(self.tr('Duration'))
            self.editDuration = QTimeEdit()
            labelDuration.setBuddy(self.editDuration)
            self.editDuration.setTime(QTime(1, 0))
            groupLayout.addWidget(labelDuration, row, 0)
            groupLayout.addWidget(self.editDuration, row, 1)
            row += 1

        groupLayout.addWidget(labelRoom, row, 0)
        groupLayout.addWidget(self.comboRoom, row, 1)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(groupLayout)

        if self.mode == 'training':
            self.tree = TeamTree(self)
            teamLayout = QVBoxLayout()
            teamLayout.addWidget(self.tree)
            groupTeams = QGroupBox(self.tr('Available teams'))
            groupTeams.setLayout(teamLayout)
            mainLayout.addWidget(groupTeams)

        self.buttonAssign = QPushButton(self.tr('Assign'))
        self.buttonCancel = QPushButton(self.tr('Cancel'))

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.buttonAssign)
        buttonLayout.addWidget(self.buttonCancel)

        if self.mode == 'rent':
            labels = QStringList([self.tr('Renter'), self.tr('Status'), self.tr('Title'),
                                  self.tr('Begin'), self.tr('End')])

            self.rent = QTableWidget(0, 5)
            self.rent.setHorizontalHeaderLabels(labels)
            rentLayout = QVBoxLayout()
            rentLayout.addWidget(self.rent)
            rentGroup = QGroupBox(self.tr('Rents'))
            rentGroup.setLayout(rentLayout)
            mainLayout.addWidget(rentGroup)

            ajax = HttpAjax(self, '/manager/get_rents/', {}, self.parent.session_id)
            response = ajax.parse_json()
            self.rent_list = response['rent_list']
            status_desc = ( self.tr('Reserved'),
                            self.tr('Paid partially'),
                            self.tr('Paid') )
            if len(self.rent_list) == 0:
                self.buttonAssign.setDisabled(True)
            for row in self.rent_list:
                lastRow = self.rent.rowCount()
                self.rent.insertRow(lastRow)

                renter = '%s %s' % (row['renter']['last_name'],
                                    row['renter']['first_name'])
                status = [self.tr('Reserved'), self.tr('Paid partially'), self.tr('Paid')][int( row['status'] )]

                self.rent.setItem(lastRow, 0, QTableWidgetItem(renter))
                self.rent.setItem(lastRow, 1, QTableWidgetItem(status))
                self.rent.setItem(lastRow, 2, QTableWidgetItem(row['title']))
                self.rent.setItem(lastRow, 3, QTableWidgetItem(row['begin_date']))
                self.rent.setItem(lastRow, 4, QTableWidgetItem(row['end_date']))

        mainLayout.addLayout(buttonLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle(self.tr('Assign the event'))
        self.setSignals()

    def setCallback(self, callback):
        self.callback = callback

    def setModel(self, model):
        self.tree.setModel(model)

    def setSignals(self):
        self.connect(self.buttonAssign, SIGNAL('clicked()'),
                     self.applyDialog)
        self.connect(self.buttonCancel, SIGNAL('clicked()'),
                     self, SLOT('reject()'))

    def setRooms(self, rooms):
        for title, color, id in rooms:
            self.comboRoom.addItem(title, QVariant(id))

    def applyDialog(self):
        e_date = self.editDate.date().toPyDate()
        e_time = self.editTime.time().toPyTime()
        index = self.comboRoom.currentIndex()
        room = self.comboRoom.itemData(index).toInt()
        if self.mode == 'training':
            index = self.tree.currentIndex()
            team = index.data(userRoles['getObjectID']).toPyObject()
            if type(team) is not list:
                return QMessageBox.warning(
                    self,
                    self.tr('Warning'),
                    '\n'.join([self.tr('What team do you want to assign?'),
                               self.tr('Choose the team on the team\'s tree.')]),
                    QMessageBox.Ok, QMessageBox.Ok)
            self.callback(e_date, e_time, room, team)
        else:
            e_duration = self.editDuration.time().toPyTime()
            rent = self.rent_list[ self.rent.currentRow() ]
            self.callback(e_date, e_time, e_duration, room, rent)
        self.accept()
Example #4
0
class DlgAssignCard(QDialog):

    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.setMinimumWidth(600)

        labelCardType = QLabel(_('Type of card'))
        self.comboCardType = QComboBox()
        labelCardType.setBuddy(self.comboCardType)
        self.comboCardType.addItem(_('Normal'))
        self.comboCardType.addItem(_('Club'))

        labelFinish = QLabel(_('Team expiress after'))
        self.comboDuration = QComboBox()
        labelFinish.setBuddy(self.comboDuration)
        self.comboDuration.addItem(_('3 months'))
        self.comboDuration.addItem(_('6 months'))
        self.comboDuration.addItem(_('9 months'))
        self.comboDuration.addItem(_('12 months'))
        self.comboDuration.setDisabled(True)

        groupLayout = QGridLayout()
        groupLayout.setColumnStretch(1, 1)
        groupLayout.setColumnMinimumWidth(1, 250)

        groupLayout.addWidget(labelCardType, 0, 0)
        groupLayout.addWidget(self.comboCardType, 0, 1)
        groupLayout.addWidget(labelFinish, 2, 0)
        groupLayout.addWidget(self.comboDuration, 2, 1)

        self.tree = TeamTree(self)

        teamLayout = QVBoxLayout()
        teamLayout.addWidget(self.tree)

        groupTeams = QGroupBox(_('Available teams'))
        groupTeams.setLayout(teamLayout)

        self.buttonAssign = QPushButton(_('Assign'))
        self.buttonCancel = QPushButton(_('Cancel'))

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.buttonAssign)
        buttonLayout.addWidget(self.buttonCancel)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(groupLayout)
        mainLayout.addWidget(groupTeams)
        mainLayout.addLayout(buttonLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle(_('Choose the team'))
        self.setSignals()

    def setCallback(self, callback):
        self.callback = callback

    def setModel(self, model):
        self.tree.setModel(model)

    def setSignals(self):
        self.connect(self.buttonAssign, SIGNAL('clicked()'),
                     self.applyDialog)
        self.connect(self.buttonCancel, SIGNAL('clicked()'),
                     self, SLOT('reject()'))
        self.connect(self.comboCardType, SIGNAL('currentIndexChanged(int)'),
                     self.changeDurationState)

    def changeDurationState(self, index):
        self.comboDuration.setDisabled(index == 0)

    def applyDialog(self):
        index = self.tree.currentIndex()
        data = {
            'card_type': self.comboCardType.currentIndex(),
            'duration': self.comboDuration.currentIndex(),
            'team': index.data(userRoles['getObjectID']).toPyObject()
            }
        self.callback(data)
        self.accept()
Example #5
0
    def __init__(self, mode='training', parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.mode = mode
        self.setMinimumWidth(600)

        labelDate = QLabel(self.tr('Date'))
        self.editDate = QDateEdit()
        labelDate.setBuddy(self.editDate)
        current = QDate.currentDate()
        self.editDate.setDate(current)
        self.editDate.setMinimumDate(current)

        labelTime = QLabel(self.tr('Time'))
        self.editTime = QTimeEdit()
        labelTime.setBuddy(self.editTime)
        current = QTime.currentTime()
        time = QTime(current.hour(), current.minute())
        self.editTime.setTime(time)

        labelRoom = QLabel(self.tr('Room'))
        self.comboRoom = QComboBox()
        labelRoom.setBuddy(self.comboRoom)

        groupLayout = QGridLayout()
        groupLayout.setColumnStretch(1, 1)
        groupLayout.setColumnMinimumWidth(1, 250)

        row = 0
        groupLayout.addWidget(labelDate, row, 0)
        groupLayout.addWidget(self.editDate, row, 1)
        row += 1
        groupLayout.addWidget(labelTime, row, 0)
        groupLayout.addWidget(self.editTime, row, 1)
        row += 1
        if self.mode == 'rent':
            labelDuration = QLabel(self.tr('Duration'))
            self.editDuration = QTimeEdit()
            labelDuration.setBuddy(self.editDuration)
            self.editDuration.setTime(QTime(1, 0))
            groupLayout.addWidget(labelDuration, row, 0)
            groupLayout.addWidget(self.editDuration, row, 1)
            row += 1

        groupLayout.addWidget(labelRoom, row, 0)
        groupLayout.addWidget(self.comboRoom, row, 1)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(groupLayout)

        if self.mode == 'training':
            self.tree = TeamTree(self)
            teamLayout = QVBoxLayout()
            teamLayout.addWidget(self.tree)
            groupTeams = QGroupBox(self.tr('Available teams'))
            groupTeams.setLayout(teamLayout)
            mainLayout.addWidget(groupTeams)

        self.buttonAssign = QPushButton(self.tr('Assign'))
        self.buttonCancel = QPushButton(self.tr('Cancel'))

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.buttonAssign)
        buttonLayout.addWidget(self.buttonCancel)

        if self.mode == 'rent':
            labels = QStringList([
                self.tr('Renter'),
                self.tr('Status'),
                self.tr('Title'),
                self.tr('Begin'),
                self.tr('End')
            ])

            self.rent = QTableWidget(0, 5)
            self.rent.setHorizontalHeaderLabels(labels)
            rentLayout = QVBoxLayout()
            rentLayout.addWidget(self.rent)
            rentGroup = QGroupBox(self.tr('Rents'))
            rentGroup.setLayout(rentLayout)
            mainLayout.addWidget(rentGroup)

            ajax = HttpAjax(self, '/manager/get_rents/', {},
                            self.parent.session_id)
            response = ajax.parse_json()
            self.rent_list = response['rent_list']
            status_desc = (self.tr('Reserved'), self.tr('Paid partially'),
                           self.tr('Paid'))
            if len(self.rent_list) == 0:
                self.buttonAssign.setDisabled(True)
            for row in self.rent_list:
                lastRow = self.rent.rowCount()
                self.rent.insertRow(lastRow)

                renter = '%s %s' % (row['renter']['last_name'],
                                    row['renter']['first_name'])
                status = [
                    self.tr('Reserved'),
                    self.tr('Paid partially'),
                    self.tr('Paid')
                ][int(row['status'])]

                self.rent.setItem(lastRow, 0, QTableWidgetItem(renter))
                self.rent.setItem(lastRow, 1, QTableWidgetItem(status))
                self.rent.setItem(lastRow, 2, QTableWidgetItem(row['title']))
                self.rent.setItem(lastRow, 3,
                                  QTableWidgetItem(row['begin_date']))
                self.rent.setItem(lastRow, 4,
                                  QTableWidgetItem(row['end_date']))

        mainLayout.addLayout(buttonLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle(self.tr('Assign the event'))
        self.setSignals()
Example #6
0
class DlgEventAssign(QDialog):
    def __init__(self, mode='training', parent=None):
        QDialog.__init__(self, parent)

        self.parent = parent
        self.mode = mode
        self.setMinimumWidth(600)

        labelDate = QLabel(self.tr('Date'))
        self.editDate = QDateEdit()
        labelDate.setBuddy(self.editDate)
        current = QDate.currentDate()
        self.editDate.setDate(current)
        self.editDate.setMinimumDate(current)

        labelTime = QLabel(self.tr('Time'))
        self.editTime = QTimeEdit()
        labelTime.setBuddy(self.editTime)
        current = QTime.currentTime()
        time = QTime(current.hour(), current.minute())
        self.editTime.setTime(time)

        labelRoom = QLabel(self.tr('Room'))
        self.comboRoom = QComboBox()
        labelRoom.setBuddy(self.comboRoom)

        groupLayout = QGridLayout()
        groupLayout.setColumnStretch(1, 1)
        groupLayout.setColumnMinimumWidth(1, 250)

        row = 0
        groupLayout.addWidget(labelDate, row, 0)
        groupLayout.addWidget(self.editDate, row, 1)
        row += 1
        groupLayout.addWidget(labelTime, row, 0)
        groupLayout.addWidget(self.editTime, row, 1)
        row += 1
        if self.mode == 'rent':
            labelDuration = QLabel(self.tr('Duration'))
            self.editDuration = QTimeEdit()
            labelDuration.setBuddy(self.editDuration)
            self.editDuration.setTime(QTime(1, 0))
            groupLayout.addWidget(labelDuration, row, 0)
            groupLayout.addWidget(self.editDuration, row, 1)
            row += 1

        groupLayout.addWidget(labelRoom, row, 0)
        groupLayout.addWidget(self.comboRoom, row, 1)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(groupLayout)

        if self.mode == 'training':
            self.tree = TeamTree(self)
            teamLayout = QVBoxLayout()
            teamLayout.addWidget(self.tree)
            groupTeams = QGroupBox(self.tr('Available teams'))
            groupTeams.setLayout(teamLayout)
            mainLayout.addWidget(groupTeams)

        self.buttonAssign = QPushButton(self.tr('Assign'))
        self.buttonCancel = QPushButton(self.tr('Cancel'))

        buttonLayout = QHBoxLayout()
        buttonLayout.addStretch(1)
        buttonLayout.addWidget(self.buttonAssign)
        buttonLayout.addWidget(self.buttonCancel)

        if self.mode == 'rent':
            labels = QStringList([
                self.tr('Renter'),
                self.tr('Status'),
                self.tr('Title'),
                self.tr('Begin'),
                self.tr('End')
            ])

            self.rent = QTableWidget(0, 5)
            self.rent.setHorizontalHeaderLabels(labels)
            rentLayout = QVBoxLayout()
            rentLayout.addWidget(self.rent)
            rentGroup = QGroupBox(self.tr('Rents'))
            rentGroup.setLayout(rentLayout)
            mainLayout.addWidget(rentGroup)

            ajax = HttpAjax(self, '/manager/get_rents/', {},
                            self.parent.session_id)
            response = ajax.parse_json()
            self.rent_list = response['rent_list']
            status_desc = (self.tr('Reserved'), self.tr('Paid partially'),
                           self.tr('Paid'))
            if len(self.rent_list) == 0:
                self.buttonAssign.setDisabled(True)
            for row in self.rent_list:
                lastRow = self.rent.rowCount()
                self.rent.insertRow(lastRow)

                renter = '%s %s' % (row['renter']['last_name'],
                                    row['renter']['first_name'])
                status = [
                    self.tr('Reserved'),
                    self.tr('Paid partially'),
                    self.tr('Paid')
                ][int(row['status'])]

                self.rent.setItem(lastRow, 0, QTableWidgetItem(renter))
                self.rent.setItem(lastRow, 1, QTableWidgetItem(status))
                self.rent.setItem(lastRow, 2, QTableWidgetItem(row['title']))
                self.rent.setItem(lastRow, 3,
                                  QTableWidgetItem(row['begin_date']))
                self.rent.setItem(lastRow, 4,
                                  QTableWidgetItem(row['end_date']))

        mainLayout.addLayout(buttonLayout)

        self.setLayout(mainLayout)
        self.setWindowTitle(self.tr('Assign the event'))
        self.setSignals()

    def setCallback(self, callback):
        self.callback = callback

    def setModel(self, model):
        self.tree.setModel(model)

    def setSignals(self):
        self.connect(self.buttonAssign, SIGNAL('clicked()'), self.applyDialog)
        self.connect(self.buttonCancel, SIGNAL('clicked()'), self,
                     SLOT('reject()'))

    def setRooms(self, rooms):
        for title, color, id in rooms:
            self.comboRoom.addItem(title, QVariant(id))

    def applyDialog(self):
        e_date = self.editDate.date().toPyDate()
        e_time = self.editTime.time().toPyTime()
        index = self.comboRoom.currentIndex()
        room = self.comboRoom.itemData(index).toInt()
        if self.mode == 'training':
            index = self.tree.currentIndex()
            team = index.data(userRoles['getObjectID']).toPyObject()
            if type(team) is not list:
                return QMessageBox.warning(
                    self, self.tr('Warning'), '\n'.join([
                        self.tr('What team do you want to assign?'),
                        self.tr('Choose the team on the team\'s tree.')
                    ]), QMessageBox.Ok, QMessageBox.Ok)
            self.callback(e_date, e_time, room, team)
        else:
            e_duration = self.editDuration.time().toPyTime()
            rent = self.rent_list[self.rent.currentRow()]
            self.callback(e_date, e_time, e_duration, room, rent)
        self.accept()