Ejemplo n.º 1
0
    def createUI(self):
        self.start_date_edit = QtGui.QDateEdit()
        self.start_date_edit.setMinimumDate(datetime.date(2015, 1, 1))
        self.start_date_edit.setToolTip("Select a start date.")
        self.start_date_edit.setMaximumDate(datetime.date.today())
        self.end_date_edit = QtGui.QDateEdit()
        self.end_date_edit.setToolTip("Select an end date.")
        self.end_date_edit.setMinimumDate(datetime.date(2015, 1, 1))
        self.end_date_edit.setMaximumDate(datetime.date.today())
        self.start_date_edit.setCalendarPopup(True)
        self.end_date_edit.setCalendarPopup(True)
        self.start_date_label = QtGui.QLabel("Select a start date:")
        self.end_date_label = QtGui.QLabel("Select an end date:")
        self.type_combo_box = CheckableComboBox("Article Type")
        self.type_combo_box.setToolTip(
            "Select what article types you want to check the helpfulness data metrics for.\nLeave as is to pull the overall metrics."
        )
        self.type_combo_box.setMinimumWidth(210)

        self.type_combo_box.addItems(["PD", "RPD", "BG"])
        self.pull_button = QtGui.QPushButton("Pull Helpfulness Data")
        self.helpfulness_report_table = QtGui.QTableWidget(0, 0)
        self.helpfulness_data_table = QtGui.QTableWidget(0, 0)
        style_string = """
        .QTableWidget {
            gridline-color: rgb(0, 0, 0);
        }
        """
        self.setStyleSheet(style_string)
        self.reports_tab = QtGui.QTabWidget()
        self.reports_tab.addTab(self.helpfulness_report_table, "Report")
        self.reports_tab.addTab(self.helpfulness_data_table, "Data")
        self.layout = QtGui.QVBoxLayout()
        self.form_layout = QtGui.QHBoxLayout()
        self.form_layout.addWidget(self.start_date_label, 0)
        self.form_layout.addWidget(self.start_date_edit, 0)
        self.form_layout.addWidget(self.end_date_label, 0)
        self.form_layout.addWidget(self.end_date_edit, 0)
        self.form_layout.addWidget(self.type_combo_box, 2)
        self.form_layout.addWidget(self.pull_button, 0)
        self.layout.addLayout(self.form_layout, 0)
        self.layout.addWidget(self.reports_tab, 1)
        self.setLayout(self.layout)
        self.setWindowTitle("Farm Hand")
        if "OINKModules" in os.getcwd():
            icon_file_name_path = os.path.join(os.path.join('..', "Images"),
                                               'PORK_Icon.png')
        else:
            icon_file_name_path = os.path.join('Images', 'PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
 def createUI(self):
     self.label = QtGui.QLabel("Description Type:")
     self.filter_box = CheckableComboBox("Description Types")
     self.filter_box.addItems(
         list(set(self.category_tree["Description Type"])))
     self.PD_button = QtGui.QPushButton("PD")
     self.RPD_button = QtGui.QPushButton("RPD")
     self.SEO_button = QtGui.QPushButton("SEO")
     self.USP_button = QtGui.QPushButton("USP")
     self.clear_button = QtGui.QPushButton("Clear")
     self.addWidget(self.label, 1)
     self.addWidget(self.filter_box, 2)
     self.addWidget(self.PD_button, 1)
     self.addWidget(self.RPD_button, 1)
     self.addWidget(self.SEO_button, 1)
     self.addWidget(self.USP_button, 1)
     self.addWidget(self.clear_button, 1)
     self.mapEvents()
Ejemplo n.º 3
0
    def createUI(self):
        self.label = QtGui.QLabel("Categories:")
        self.bu_combo_box = CheckableComboBox("BU")
        self.super_category_combo_box = CheckableComboBox("Super-Category")
        self.category_combo_box = CheckableComboBox("Category")
        self.sub_category_combo_box = CheckableComboBox("Sub-Category")
        self.vertical_combo_box = CheckableComboBox("Vertical")
        self.category_finder = CategoryFinder(self.category_tree)
        self.clear_button = QtGui.QPushButton("Clear\nFilters")
        row_1 = QtGui.QHBoxLayout()
        row_1.addWidget(self.label, 0)
        row_1.addWidget(self.bu_combo_box, 1)
        row_1.addWidget(self.super_category_combo_box, 1)
        row_1.addWidget(self.category_combo_box, 1)
        row_2 = QtGui.QHBoxLayout()
        row_2.addWidget(self.sub_category_combo_box)
        row_2.addWidget(self.vertical_combo_box)
        row_2.addStretch(2)
        row_2.addWidget(self.clear_button)

        self.addLayout(row_1)
        self.addLayout(row_2)
        self.addLayout(self.category_finder)
Ejemplo n.º 4
0
    def createUI(self):
        self.start_date_edit = QtGui.QDateEdit()
        self.start_date_edit.setMinimumDate(datetime.date(2015,1,1))
        self.start_date_edit.setToolTip("Select a start date.")
        self.start_date_edit.setMaximumDate(datetime.date.today())
        self.end_date_edit = QtGui.QDateEdit()
        self.end_date_edit.setToolTip("Select an end date.")
        self.end_date_edit.setMinimumDate(datetime.date(2015,1,1))
        self.end_date_edit.setMaximumDate(datetime.date.today())
        self.start_date_edit.setCalendarPopup(True)
        self.end_date_edit.setCalendarPopup(True)
        self.start_date_label = QtGui.QLabel("Select a start date:")
        self.end_date_label = QtGui.QLabel("Select an end date:")
        self.type_combo_box = CheckableComboBox("Article Type")
        self.type_combo_box.setToolTip("Select what article types you want to check the helpfulness data metrics for.\nLeave as is to pull the overall metrics.")
        self.type_combo_box.setMinimumWidth(210)

        self.type_combo_box.addItems(["PD","RPD","BG"])
        self.pull_button = QtGui.QPushButton("Pull Helpfulness Data")
        self.helpfulness_report_table = QtGui.QTableWidget(0,0)
        self.helpfulness_data_table = QtGui.QTableWidget(0,0)
        style_string = """
        .QTableWidget {
            gridline-color: rgb(0, 0, 0);
        }
        """
        self.setStyleSheet(style_string)
        self.reports_tab = QtGui.QTabWidget()
        self.reports_tab.addTab(self.helpfulness_report_table,"Report")
        self.reports_tab.addTab(self.helpfulness_data_table,"Data")
        self.layout = QtGui.QVBoxLayout()
        self.form_layout = QtGui.QHBoxLayout()
        self.form_layout.addWidget(self.start_date_label,0)
        self.form_layout.addWidget(self.start_date_edit,0)
        self.form_layout.addWidget(self.end_date_label,0)
        self.form_layout.addWidget(self.end_date_edit,0)
        self.form_layout.addWidget(self.type_combo_box,2)
        self.form_layout.addWidget(self.pull_button,0)
        self.layout.addLayout(self.form_layout,0)
        self.layout.addWidget(self.reports_tab,1)
        self.setLayout(self.layout)
        self.setWindowTitle("Farm Hand")
        if "OINKModules" in os.getcwd():
            icon_file_name_path = os.path.join(os.path.join('..',"Images"),'PORK_Icon.png')
        else:
            icon_file_name_path = os.path.join('Images','PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
Ejemplo n.º 5
0
 def createUI(self):
     self.label = QtGui.QLabel("Description Type:")
     self.filter_box = CheckableComboBox("Description Types")
     self.filter_box.addItems(list(set(self.category_tree["Description Type"])))
     self.PD_button = QtGui.QPushButton("PD")
     self.RPD_button = QtGui.QPushButton("RPD")
     self.SEO_button = QtGui.QPushButton("SEO")
     self.USP_button = QtGui.QPushButton("USP")
     self.clear_button = QtGui.QPushButton("Clear")
     self.addWidget(self.label,1)
     self.addWidget(self.filter_box,2)
     self.addWidget(self.PD_button,1)
     self.addWidget(self.RPD_button,1)
     self.addWidget(self.SEO_button,1)
     self.addWidget(self.USP_button,1)
     self.addWidget(self.clear_button,1)
     self.mapEvents()
Ejemplo n.º 6
0
    def createUI(self):
        self.filter_label = QtGui.QLabel("Label:")
        self.filter_legend = QtGui.QLineEdit()
        self.filter_legend.setToolTip(
            "Type a meaningful name for this data set here.\nTry avoiding special characters as they could result in errors."
        )

        self.writer_label = QtGui.QLabel("Writer(s):")
        self.writer_combobox = CheckableComboBox("Writers")
        self.editor_label = QtGui.QLabel("Editor(s):")
        self.editor_combobox = CheckableComboBox("Editors")

        self.writer_all_button = QtGui.QPushButton("All")
        self.writer_all_button.setToolTip("Select all writers")
        self.writer_clear_button = QtGui.QPushButton("Clear")
        self.writer_clear_button.setToolTip("Clear writer selection")

        self.editor_all_button = QtGui.QPushButton("All")
        self.editor_all_button.setToolTip("Select all editors")
        self.editor_clear_button = QtGui.QPushButton("Clear")
        self.editor_clear_button.setToolTip("Clear editor selection")

        self.pd_button = QtGui.QPushButton("PD")
        self.rpd_button = QtGui.QPushButton("RPD")
        self.seo_button = QtGui.QPushButton("SEO")
        self.all_button = QtGui.QPushButton("All")

        self.all_button.setFixedWidth(30)
        self.rpd_button.setFixedWidth(30)
        self.pd_button.setFixedWidth(30)
        self.seo_button.setFixedWidth(30)

        self.all_button.setCheckable(True)
        self.rpd_button.setCheckable(True)
        self.pd_button.setCheckable(True)
        self.seo_button.setCheckable(True)

        self.date_field_label = QtGui.QLabel("Date Range:")
        self.date_field_start = QtGui.QDateEdit()
        self.date_field_end = QtGui.QDateEdit()
        self.date_field_start.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_start.setMaximumDate(datetime.date.today())
        self.date_field_start.setDate(datetime.date.today())
        self.date_field_start.setCalendarPopup(True)
        self.date_field_end.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_end.setMaximumDate(datetime.date.today())
        self.date_field_end.setDate(datetime.date.today())
        self.date_field_end.setCalendarPopup(True)
        self.select_all_data = QtGui.QCheckBox("Select all audits")
        self.graph_color_label = QtGui.QLabel("Graph Color")
        self.graph_color_button = QColorButton()
        self.category_selector = CategorySelector(self.category_tree)

        row_0_layout = QtGui.QHBoxLayout()
        row_0_layout.addWidget(self.filter_label, 0)
        row_0_layout.addWidget(self.filter_legend, 1)

        row_1_layout = QtGui.QHBoxLayout()
        row_1_layout.addWidget(self.writer_label, 0)
        row_1_layout.addWidget(self.writer_combobox, 1)
        row_1_layout.addWidget(self.writer_all_button, 0)
        row_1_layout.addWidget(self.writer_clear_button, 0)
        row_1_layout.addStretch(1)

        row_2_layout = QtGui.QHBoxLayout()
        row_2_layout.addWidget(self.editor_label, 0)
        row_2_layout.addWidget(self.editor_combobox, 1)
        row_2_layout.addWidget(self.editor_all_button, 0)
        row_2_layout.addWidget(self.editor_clear_button, 0)
        row_2_layout.addWidget(self.graph_color_label, 0)
        row_2_layout.addWidget(self.graph_color_button, 0)
        row_2_layout.addStretch(1)

        row_3_layout = QtGui.QHBoxLayout()
        row_3_layout.addWidget(self.date_field_label, 0)
        row_3_layout.addWidget(self.date_field_start, 0)
        row_3_layout.addWidget(self.date_field_end, 0)
        row_3_layout.addWidget(self.select_all_data, 0)
        row_3_layout.addWidget(self.pd_button, 0)
        row_3_layout.addWidget(self.rpd_button, 0)
        row_3_layout.addWidget(self.seo_button, 0)
        row_3_layout.addWidget(self.all_button, 0)
        row_3_layout.addStretch(1)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_0_layout, 1)
        layout.addLayout(row_1_layout, 1)
        layout.addLayout(row_2_layout, 1)
        layout.addLayout(row_3_layout, 1)
        layout.addLayout(self.category_selector, 2)
        self.setLayout(layout)
Ejemplo n.º 7
0
class FilterForm(QtGui.QGroupBox):
    changedStartDate = QtCore.pyqtSignal()
    changedFilter = QtCore.pyqtSignal()

    def __init__(self, user_id, password, color, category_tree, *args,
                 **kwargs):
        super(FilterForm, self).__init__(*args, **kwargs)
        self.user_id = user_id
        self.password = password
        self.category_tree = category_tree
        self.user_name = MOSES.getEmpName(self.user_id)
        self.lock_mode = None
        self.createUI()
        self.mapEvents()
        self.all_button.setChecked(True)
        label = str(args[0]) if args is not None else "Data Set"
        self.filter_legend.setText(label)

    def createUI(self):
        self.filter_label = QtGui.QLabel("Label:")
        self.filter_legend = QtGui.QLineEdit()
        self.filter_legend.setToolTip(
            "Type a meaningful name for this data set here.\nTry avoiding special characters as they could result in errors."
        )

        self.writer_label = QtGui.QLabel("Writer(s):")
        self.writer_combobox = CheckableComboBox("Writers")
        self.editor_label = QtGui.QLabel("Editor(s):")
        self.editor_combobox = CheckableComboBox("Editors")

        self.writer_all_button = QtGui.QPushButton("All")
        self.writer_all_button.setToolTip("Select all writers")
        self.writer_clear_button = QtGui.QPushButton("Clear")
        self.writer_clear_button.setToolTip("Clear writer selection")

        self.editor_all_button = QtGui.QPushButton("All")
        self.editor_all_button.setToolTip("Select all editors")
        self.editor_clear_button = QtGui.QPushButton("Clear")
        self.editor_clear_button.setToolTip("Clear editor selection")

        self.pd_button = QtGui.QPushButton("PD")
        self.rpd_button = QtGui.QPushButton("RPD")
        self.seo_button = QtGui.QPushButton("SEO")
        self.all_button = QtGui.QPushButton("All")

        self.all_button.setFixedWidth(30)
        self.rpd_button.setFixedWidth(30)
        self.pd_button.setFixedWidth(30)
        self.seo_button.setFixedWidth(30)

        self.all_button.setCheckable(True)
        self.rpd_button.setCheckable(True)
        self.pd_button.setCheckable(True)
        self.seo_button.setCheckable(True)

        self.date_field_label = QtGui.QLabel("Date Range:")
        self.date_field_start = QtGui.QDateEdit()
        self.date_field_end = QtGui.QDateEdit()
        self.date_field_start.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_start.setMaximumDate(datetime.date.today())
        self.date_field_start.setDate(datetime.date.today())
        self.date_field_start.setCalendarPopup(True)
        self.date_field_end.setMinimumDate(datetime.date(2015, 1, 1))
        self.date_field_end.setMaximumDate(datetime.date.today())
        self.date_field_end.setDate(datetime.date.today())
        self.date_field_end.setCalendarPopup(True)
        self.select_all_data = QtGui.QCheckBox("Select all audits")
        self.graph_color_label = QtGui.QLabel("Graph Color")
        self.graph_color_button = QColorButton()
        self.category_selector = CategorySelector(self.category_tree)

        row_0_layout = QtGui.QHBoxLayout()
        row_0_layout.addWidget(self.filter_label, 0)
        row_0_layout.addWidget(self.filter_legend, 1)

        row_1_layout = QtGui.QHBoxLayout()
        row_1_layout.addWidget(self.writer_label, 0)
        row_1_layout.addWidget(self.writer_combobox, 1)
        row_1_layout.addWidget(self.writer_all_button, 0)
        row_1_layout.addWidget(self.writer_clear_button, 0)
        row_1_layout.addStretch(1)

        row_2_layout = QtGui.QHBoxLayout()
        row_2_layout.addWidget(self.editor_label, 0)
        row_2_layout.addWidget(self.editor_combobox, 1)
        row_2_layout.addWidget(self.editor_all_button, 0)
        row_2_layout.addWidget(self.editor_clear_button, 0)
        row_2_layout.addWidget(self.graph_color_label, 0)
        row_2_layout.addWidget(self.graph_color_button, 0)
        row_2_layout.addStretch(1)

        row_3_layout = QtGui.QHBoxLayout()
        row_3_layout.addWidget(self.date_field_label, 0)
        row_3_layout.addWidget(self.date_field_start, 0)
        row_3_layout.addWidget(self.date_field_end, 0)
        row_3_layout.addWidget(self.select_all_data, 0)
        row_3_layout.addWidget(self.pd_button, 0)
        row_3_layout.addWidget(self.rpd_button, 0)
        row_3_layout.addWidget(self.seo_button, 0)
        row_3_layout.addWidget(self.all_button, 0)
        row_3_layout.addStretch(1)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_0_layout, 1)
        layout.addLayout(row_1_layout, 1)
        layout.addLayout(row_2_layout, 1)
        layout.addLayout(row_3_layout, 1)
        layout.addLayout(self.category_selector, 2)
        self.setLayout(layout)

    def lock(self, lock_mode=None):
        if lock_mode is not None:
            self.lock_mode = lock_mode
        if self.lock_mode is not None:
            self.editor_combobox.clearSelection()
            self.editor_combobox.setEnabled(False)
            self.editor_all_button.setEnabled(False)
            self.editor_clear_button.setEnabled(False)
            if self.lock_mode == 1:
                self.writer_combobox.clearSelection()
                self.writer_combobox.select(self.user_name)
                self.writer_combobox.setEnabled(False)
                self.writer_all_button.setEnabled(False)
                self.writer_clear_button.setEnabled(False)
            elif self.lock_mode == 2:
                self.writer_combobox.clearSelection()
                self.writer_combobox.selectAll()
                self.writer_combobox.setEnabled(False)

    def mapEvents(self):
        self.all_button.toggled.connect(self.toggleAll)
        self.pd_button.toggled.connect(self.toggleTypes)
        self.rpd_button.toggled.connect(self.toggleTypes)
        self.seo_button.toggled.connect(self.toggleTypes)

        self.select_all_data.toggled.connect(self.changeDateType)
        self.writer_all_button.clicked.connect(self.selectAllWriters)
        self.writer_clear_button.clicked.connect(self.clearWriters)
        self.editor_all_button.clicked.connect(self.selectAllEditors)
        self.editor_clear_button.clicked.connect(self.clearEditors)

        self.date_field_start.dateChanged.connect(self.changedDate)

        #Any change in the filter form should result in emitting the changedFilter signal.
        self.date_field_start.dateChanged.connect(self.changedFilter)
        self.date_field_end.dateChanged.connect(self.changedFilter)
        self.all_button.toggled.connect(self.changedFilter)
        self.pd_button.toggled.connect(self.changedFilter)
        self.rpd_button.toggled.connect(self.changedFilter)
        self.seo_button.toggled.connect(self.changedFilter)
        self.select_all_data.toggled.connect(self.changedFilter)
        self.writer_combobox.changedSelection.connect(self.changedFilter)
        self.editor_combobox.changedSelection.connect(self.changedFilter)
        self.category_selector.changedCategorySelection.connect(
            self.changedFilter)

    def changedDate(self):
        self.changedStartDate.emit()

    def selectAllWriters(self):
        self.writer_combobox.selectAll()

    def selectAllEditors(self):
        self.editor_combobox.selectAll()

    def clearWriters(self):
        self.writer_combobox.clearSelection()
        if self.lock_mode is not None:
            if self.lock_mode == 2:
                self.writer_combobox.select(self.user_name)

    def clearEditors(self):
        self.editor_combobox.clearSelection()

    def changeDateType(self):
        if self.select_all_data.isChecked():
            self.date_field_start.setEnabled(False)
            self.date_field_end.setEnabled(False)
        else:
            self.date_field_start.setEnabled(True)
            self.date_field_end.setEnabled(True)

    def getLabel(self):
        return str(self.filter_legend.text()).strip()

    def toggleAll(self):
        if self.all_button.isChecked():
            self.pd_button.setChecked(True)
            self.rpd_button.setChecked(True)
            self.seo_button.setChecked(True)
            self.all_button.setEnabled(False)

    def toggleTypes(self):
        if self.pd_button.isChecked() and self.rpd_button.isChecked(
        ) and self.seo_button.isChecked():
            self.all_button.setChecked(True)
            self.all_button.setEnabled(False)
        else:
            self.all_button.setEnabled(True)
            self.all_button.setChecked(False)

    def getFilters(self):
        category_tree_filter = self.category_selector.getFilters()

        writer_filter = self.writer_combobox.getCheckedItems()
        editor_filter = self.editor_combobox.getCheckedItems()

        start_date = self.date_field_start.date().toPyDate()
        end_date = self.date_field_end.date().toPyDate()

        get_pd = False
        get_rpd = False
        get_seo = False

        if self.all_button.isChecked():
            get_pd = True
            get_rpd = True
            get_seo = True
        else:
            if self.pd_button.isChecked():
                get_pd = True
            if self.rpd_button.isChecked():
                get_rpd = True
            if self.seo_button.isChecked():
                get_seo = True

        description_type = []
        if get_pd:
            description_type.append("PD")
        if get_rpd:
            description_type.append("RPD")
        if get_seo:
            description_type.append("SEO")

        filter_settings = {
            "Category Tree":
            category_tree_filter
            if category_tree_filter.shape[0] > 0 else None,
            "Writers":
            writer_filter if len(writer_filter) > 0 else None,
            "Editors":
            editor_filter if len(editor_filter) > 0 else None,
            "Dates": [start_date, end_date]
            if not (self.select_all_data.isChecked()) else None,
            "Description Types":
            description_type if len(description_type) > 0 else None
        }
        return filter_settings

    def getGraphColor(self):
        return self.graph_color_button.getColor()

    def populateFilter(self):
        pass

    def populateEditorAndWritersList(self):
        comparison_date = self.date_field_end.date().toPyDate()
        self.writer_and_editor_dataframe = MOSES.getWriterAndEditorData(
            self.user_id, self.password, comparison_date)
        self.writers_list = list(
            set(self.writer_and_editor_dataframe["Writer Name"]))
        self.editors_list = list(
            set(self.writer_and_editor_dataframe["Editor Name"]))
        self.writers_list.sort()
        self.editors_list.sort()
        self.writer_combobox.clear()
        self.writer_combobox.addItems(self.writers_list)
        self.editor_combobox.clear()
        self.editor_combobox.addItems(self.editors_list)

    def getDates(self):
        if self.select_all_data.isChecked():
            return datetime.date(2015, 1, 1), datetime.date.today()
        else:
            return self.date_field_start.date().toPyDate(
            ), self.date_field_end.date().toPyDate()

    def getData(self):
        pass
Ejemplo n.º 8
0
class LeaveApproval(QtGui.QWidget):
    def __init__(self, user_id, password, *args, **kwargs):
        super(LeaveApproval, self).__init__(*args, **kwargs)
        self.user_id, self.password = user_id, password
        self.work_calendar = None
        self.selected_name = False
        self.createUI()
        self.initiate()
        self.mapEvents()
        self.applyFilters()

    def createUI(self):
        self.date_label = QtGui.QLabel("Date(s):")
        self.start_date = FormattedDateEdit()
        self.end_date = FormattedDateEdit()

        self.employees_label = QtGui.QLabel("Employees:")
        self.employees_selection_box = CheckableComboBox("Employees")
        self.all_button = QtGui.QPushButton("Select All")
        self.clear_button = QtGui.QPushButton("Clear")

        self.refresh_table_button = QtGui.QPushButton("Refresh Table")
        self.approve_selected_button = QtGui.QPushButton("Approved")
        self.approve_selected_button.setCheckable(True)
        self.reject_selected_button = QtGui.QPushButton("Rejected")
        self.reject_selected_button.setCheckable(True)
        self.pending_selected_button = QtGui.QPushButton("Pending")
        self.pending_selected_button.setCheckable(True)

        self.button_group = QtGui.QButtonGroup()
        self.button_group.addButton(self.approve_selected_button)
        self.button_group.addButton(self.reject_selected_button)
        self.button_group.addButton(self.pending_selected_button)
        self.button_group.setExclusive(True)

        self.approval_comment_label = QtGui.QLabel(
            "Approval\\Rejection Comment:")
        self.rejection_comment_lineedit = QtGui.QLineEdit()

        self.leave_table = CopiableQTableWidget(0, 0)

        self.status_label = QtGui.QLabel("Status")
        self.status_combobox = QtGui.QComboBox()
        self.status_combobox.addItems(["Working", "Leave"])
        self.comment_label = QtGui.QLabel("Comment")
        self.comment_lineedit = QtGui.QLineEdit()
        self.save_selected_button = QtGui.QPushButton("Save")
        self.save_selected_button.setEnabled(False)
        self.save_all_button = QtGui.QPushButton("Save All")

        row_1 = QtGui.QHBoxLayout()
        row_1.addWidget(self.date_label, 0)
        row_1.addWidget(self.start_date, 0)
        row_1.addWidget(self.end_date, 0)
        row_1.addWidget(self.employees_label, 0)
        row_1.addWidget(self.employees_selection_box, 0)
        row_1.addWidget(self.all_button, 0)
        row_1.addWidget(self.clear_button, 0)

        self.relaxation_label = QtGui.QLabel("Relaxation")
        self.relaxation_spinbox = QtGui.QDoubleSpinBox()
        self.relaxation_spinbox.setSuffix("%")

        row_2 = QtGui.QHBoxLayout()
        row_2.addWidget(self.status_label, 0)
        row_2.addWidget(self.status_combobox, 0)
        row_2.addWidget(self.relaxation_label, 0)
        row_2.addWidget(self.relaxation_spinbox, 0)
        row_2.addWidget(self.comment_label, 0)
        row_2.addWidget(self.comment_lineedit, 0)

        row_3 = QtGui.QHBoxLayout()
        row_3.addWidget(self.approval_comment_label, 0)
        row_3.addWidget(self.rejection_comment_lineedit, 0)
        row_3.addWidget(self.approve_selected_button, 0)
        row_3.addWidget(self.reject_selected_button, 0)
        row_3.addWidget(self.pending_selected_button, 0)
        row_3.addWidget(self.save_selected_button, 0)
        row_3.addWidget(self.save_all_button, 0)
        row_3.addWidget(self.refresh_table_button, 0)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_1)
        layout.addLayout(row_2)
        layout.addLayout(row_3)
        layout.addWidget(self.leave_table)

        self.setLayout(layout)
        self.setWindowTitle("Leaves Manager")
        self.setWindowIcon(
            QtGui.QIcon(os.path.join(MOSES.getPathToImages(),
                                     "PORK_Icon.png")))
        self.show()

    def mapEvents(self):
        self.start_date.dateChanged.connect(self.startDateChanged)
        self.end_date.dateChanged.connect(self.applyFilters)
        self.refresh_table_button.clicked.connect(self.applyFilters)
        self.clear_button.clicked.connect(
            self.employees_selection_box.clearSelection)
        self.leave_table.currentCellChanged.connect(self.populateForm)
        self.employees_selection_box.changedSelection.connect(
            self.applyFilters)
        self.save_selected_button.clicked.connect(self.saveSelected)
        self.save_all_button.clicked.connect(self.saveAll)
        self.all_button.clicked.connect(self.employees_selection_box.selectAll)

    def saveSelected(self):
        if self.selected_name:
            self.saveThese([self.selected_name])
        else:
            self.alertMessage(
                "Select a row",
                "Select a row in the work calendar and then try again.")
            self.save_selected_button.setEnabled(False)

    def saveAll(self):
        self.saveThese(self.employees_selection_box.getCheckedItems())

    def saveThese(self, selected_names):
        selected_employee_ids = [
            list(self.employees_list[self.employees_list["Name"] == x]
                 ["Employee ID"])[0] for x in selected_names
        ]
        dates = [
            self.start_date.date().toPyDate(),
            self.end_date.date().toPyDate()
        ]
        allow_continue = False
        if (len(selected_employee_ids) > 1) and (dates[0] == dates[1]):
            ask = QtGui.QMessageBox.question(
                self, 'Multiple Employees Selected!',
                "You appear to have chosen the ids of several employees. Click yes if you'd like to continue modifying the work calendar for all their names. If not, click no and select only one employee's name.",
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                QtGui.QMessageBox.No)
            if ask == QtGui.QMessageBox.Yes:
                allow_continue = True
        elif (len(selected_employee_ids) > 1) and (dates[0] < dates[1]):
            ask = QtGui.QMessageBox.question(
                self, 'Multiple Dates and Employees Selected!',
                "You appear to have chosen the ids of several employees and an entire date range. Are you sure that you want to apply the settings for all of them for all these dates? I'd recommend changing the status of one employee for one date at a time. Click yes if you'd like to continue modifying the work calendar for all their names for those dates. If not, click no and select only one employee's name and one date.",
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                QtGui.QMessageBox.No)
            if ask == QtGui.QMessageBox.Yes:
                allow_continue = True
        elif (len(selected_employee_ids) == 1) and (dates[0] < dates[1]):
            ask = QtGui.QMessageBox.question(
                self, 'Multiple Dates Selected!',
                "You appear to have chosen an entire date range. Are you sure that you want to apply the settings for the selected employee all these dates? I'd recommend changing the status of one employee for one date at a time. Click yes if you'd like to continue modifying the work calendar for all their names for those dates. If not, click no and select only one date.",
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                QtGui.QMessageBox.No)
            if ask == QtGui.QMessageBox.Yes:
                allow_continue = True
        elif (len(selected_employee_ids) <= 0):
            self.alertMessage(
                'No Employees Selected!',
                "Please select an employee in order to process the work status and relaxation."
            )
        else:
            allow_continue = True

        if allow_continue:
            status = str(self.status_combobox.currentText())
            relaxation = self.relaxation_spinbox.value() / 100
            comment = str(self.comment_lineedit.text())
            if self.approve_selected_button.isChecked():
                approval = "Approved"
            elif self.reject_selected_button.isChecked():
                approval = "Rejected"
            else:
                approval = "Pending"
            approval_comment = str(self.rejection_comment_lineedit.text())
            self.alertMessage(
                "Please Wait",
                "This could take a while. Click OK and hold on to your horses."
            )
            update = MOSES.updateWorkCalendarFor(self.user_id, self.password,
                                                 status, relaxation, comment,
                                                 approval, approval_comment,
                                                 dates, selected_employee_ids)
            if update:
                self.alertMessage("Success",
                                  "Successfully updated the Work Calendar")
                self.applyFilters()
            else:
                self.alertMessage("Failure",
                                  "Failed in updating the Work Calendar")

        else:
            print "Not allowed to continue"

    def initiate(self):
        self.start_date.setDate(datetime.date.today())
        self.start_date.setMinimumDate(datetime.date(2015, 1, 1))
        self.end_date.setDate(self.start_date.date())
        self.end_date.setMinimumDate(self.start_date.date())
        self.employees_list = MOSES.getEmployeesList(
            self.user_id, self.password,
            self.end_date.date().toPyDate())
        self.employees_selection_box.clear()
        self.employees_selection_box.addItems(
            sorted(list(self.employees_list["Name"])))
        self.employees_selection_box.selectAll()

    def applyFilters(self):
        self.leave_table.showDataFrame(None)
        selected_employee_ids = [
            list(self.employees_list[self.employees_list["Name"] == x]
                 ["Employee ID"])[0]
            for x in self.employees_selection_box.getCheckedItems()
        ]
        if len(selected_employee_ids) <= 0:
            self.alertMessage("No Employees Selected",
                              "Select at least one employee!")
        else:
            filter_dict = {
                "Dates": [
                    self.start_date.date().toPyDate(),
                    self.end_date.date().toPyDate()
                ],
                "Employee IDs":
                selected_employee_ids
            }
            time_diff = (filter_dict["Dates"][1] - filter_dict["Dates"][0])
            if datetime.timedelta(days=5) < time_diff < datetime.timedelta(
                    days=30):
                self.alertMessage(
                    "Please Wait",
                    "The work calendar is being refreshed. This may take a while since you've selected over a week's worth of data."
                )
            elif time_diff >= datetime.timedelta(days=30):
                self.alertMessage(
                    "Please Wait",
                    "The work calendar is being refreshed. This will take quite some time longer than usual since you've selected a date range wider than or equal to 30 days."
                )

            self.work_calendar = MOSES.getWorkCalendarFor(
                self.user_id, self.password, filter_dict)
            self.alertMessage("Success", "Retrieved the Work Calendar")
            yellow = QtGui.QColor(200, 200, 0)
            green = QtGui.QColor(0, 153, 0)
            red = QtGui.QColor(170, 0, 0)

            highlight_rules = [{
                "Columns": ["Status", "Approval"],
                "Values": ["Leave", "Approved"],
                "Color": green
            }, {
                "Columns": ["Status", "Approval"],
                "Values": ["Leave", "Pending"],
                "Color": yellow
            }, {
                "Columns": ["Status", "Approval"],
                "Values": ["Leave", "Rejected"],
                "Color": red
            }, {
                "Columns": ["Relaxation", "Approval"],
                "Values": [[0.01, 1.00], "Approved"],
                "Color": green
            }, {
                "Columns": ["Relaxation", "Approval"],
                "Values": [[0.01, 1.00], "Pending"],
                "Color": yellow
            }, {
                "Columns": ["Relaxation", "Approval"],
                "Values": [[0.01, 1.00], "Rejected"],
                "Color": red
            }]
            self.leave_table.showDataFrame(self.work_calendar, highlight_rules)
            self.leave_table.setSortingEnabled(False)

    def startDateChanged(self):
        self.end_date.setDate(self.start_date.date())
        self.end_date.setMinimumDate(self.start_date.date())
        self.applyFilters()

    def populateForm(self, row=None, column=None):
        if self.work_calendar is not None:
            #rows = sorted(set(index.row() for index in self.leave_table.selectedIndexes()))
            try:
                selected_row = self.work_calendar.loc[row]
                self.selected_name = selected_row["Employee Name"]
                status = selected_row["Status"]
                relaxation = selected_row["Relaxation"]
                comment = selected_row["Comment"]
                approval = selected_row["Approval"]
                rejection_comment = selected_row["Rejection Comment"]
                date_ = selected_row["Date"]
                self.save_selected_button.setText("Save %s's entry" %
                                                  self.selected_name)
                self.save_selected_button.setEnabled(True)
            except:
                self.selected_name = None
                self.save_selected_button.setText("Save Selected")
                self.save_selected_button.setEnabled(False)
                comment = ""
                relaxation = 0.0
                rejection_comment = ""
                status = "Working"
                approval = "Pending"

            self.comment_lineedit.setText(
                comment if comment is not None else "")
            self.status_combobox.setCurrentIndex(
                self.status_combobox.findText(status))
            self.rejection_comment_lineedit.setText(
                rejection_comment if rejection_comment is not None else "")
            self.relaxation_spinbox.setValue((relaxation * 100))
            if approval is not None:
                if approval == "Approved":
                    self.approve_selected_button.setChecked(True)
                elif approval == "Rejected":
                    self.reject_selected_button.setChecked(True)
                else:
                    self.pending_selected_button.setChecked(True)
            else:
                print "Approval is None!"

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)
Ejemplo n.º 9
0
class FarmHand(QtGui.QWidget):
    def __init__(self, user_id, password):
        super(FarmHand, self).__init__()
        self.user_id, self.password = user_id, password
        self.createUI()
        self.mapEvents()
        self.clip = QtGui.QApplication.clipboard()
        self.show()

    def createUI(self):
        self.start_date_edit = QtGui.QDateEdit()
        self.start_date_edit.setMinimumDate(datetime.date(2015, 1, 1))
        self.start_date_edit.setToolTip("Select a start date.")
        self.start_date_edit.setMaximumDate(datetime.date.today())
        self.end_date_edit = QtGui.QDateEdit()
        self.end_date_edit.setToolTip("Select an end date.")
        self.end_date_edit.setMinimumDate(datetime.date(2015, 1, 1))
        self.end_date_edit.setMaximumDate(datetime.date.today())
        self.start_date_edit.setCalendarPopup(True)
        self.end_date_edit.setCalendarPopup(True)
        self.start_date_label = QtGui.QLabel("Select a start date:")
        self.end_date_label = QtGui.QLabel("Select an end date:")
        self.type_combo_box = CheckableComboBox("Article Type")
        self.type_combo_box.setToolTip(
            "Select what article types you want to check the helpfulness data metrics for.\nLeave as is to pull the overall metrics."
        )
        self.type_combo_box.setMinimumWidth(210)

        self.type_combo_box.addItems(["PD", "RPD", "BG"])
        self.pull_button = QtGui.QPushButton("Pull Helpfulness Data")
        self.helpfulness_report_table = QtGui.QTableWidget(0, 0)
        self.helpfulness_data_table = QtGui.QTableWidget(0, 0)
        style_string = """
        .QTableWidget {
            gridline-color: rgb(0, 0, 0);
        }
        """
        self.setStyleSheet(style_string)
        self.reports_tab = QtGui.QTabWidget()
        self.reports_tab.addTab(self.helpfulness_report_table, "Report")
        self.reports_tab.addTab(self.helpfulness_data_table, "Data")
        self.layout = QtGui.QVBoxLayout()
        self.form_layout = QtGui.QHBoxLayout()
        self.form_layout.addWidget(self.start_date_label, 0)
        self.form_layout.addWidget(self.start_date_edit, 0)
        self.form_layout.addWidget(self.end_date_label, 0)
        self.form_layout.addWidget(self.end_date_edit, 0)
        self.form_layout.addWidget(self.type_combo_box, 2)
        self.form_layout.addWidget(self.pull_button, 0)
        self.layout.addLayout(self.form_layout, 0)
        self.layout.addWidget(self.reports_tab, 1)
        self.setLayout(self.layout)
        self.setWindowTitle("Farm Hand")
        if "OINKModules" in os.getcwd():
            icon_file_name_path = os.path.join(os.path.join('..', "Images"),
                                               'PORK_Icon.png')
        else:
            icon_file_name_path = os.path.join('Images', 'PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))

    def mapEvents(self):
        self.start_date_edit.dateChanged.connect(self.limitEndDate)
        self.pull_button.clicked.connect(self.populateReport)

    def keyPressEvent(self, e):
        if (e.modifiers() & QtCore.Qt.ControlModifier):
            if e.key() == QtCore.Qt.Key_C:
                current_tab = self.reports_tab.currentIndex()

                if current_tab == 0:
                    table_to_copy = self.helpfulness_report_table
                else:
                    table_to_copy = self.helpfulness_data_table

                selected = table_to_copy.selectedRanges()
                s = '\t' + "\t".join([
                    str(table_to_copy.horizontalHeaderItem(i).text())
                    for i in xrange(selected[0].leftColumn(),
                                    selected[0].rightColumn() + 1)
                ])
                s = s + '\n'
                for r in xrange(selected[0].topRow(),
                                selected[0].bottomRow() + 1):
                    s += str(r + 1) + '\t'
                    for c in xrange(selected[0].leftColumn(),
                                    selected[0].rightColumn() + 1):
                        try:
                            s += str(table_to_copy.item(r, c).text()) + "\t"
                        except AttributeError:
                            s += "\t"
                    s = s[:-1] + "\n"  #eliminate last '\t'
                self.clip.setText(s)

    def populateReport(self):
        #        print "Populating report"
        entity_types = self.type_combo_box.getCheckedItems()
        if len(entity_types) == 0:
            entity_types = None
        data = MOSES.getFeedbackBetweenDates(
            self.user_id, self.password,
            self.start_date_edit.date().toPyDate(),
            self.end_date_edit.date().toPyDate(), entity_types)
        if data["total"] != 0:
            self.helpfulness_report_table.setRowCount(1)
            self.helpfulness_report_table.setColumnCount(4)
            self.helpfulness_report_table.setHorizontalHeaderLabels(
                ["Yes", "No", "Total", "Helpfulness%"])
            self.helpfulness_report_table.setItem(
                0, 0, QtGui.QTableWidgetItem(str(data["yes"])))
            self.helpfulness_report_table.setItem(
                0, 1, QtGui.QTableWidgetItem(str(data["total"] - data["yes"])))
            self.helpfulness_report_table.setItem(
                0, 2, QtGui.QTableWidgetItem(str(data["total"])))
            self.helpfulness_report_table.setItem(
                0, 3,
                QtGui.QTableWidgetItem("%.2f%%" %
                                       (100 * data["yes"] / data["total"])))
            #print data["data"][0].keys()
            data_headers = [
                "Time Stamp", "Article Type", "Item ID", "FSN", "Feedback",
                "Feedback Comment"
            ]
            table_rows = len(data["data"])
            self.helpfulness_data_table.setSortingEnabled(False)
            self.helpfulness_data_table.setRowCount(table_rows)
            self.helpfulness_data_table.setColumnCount(len(data_headers))
            self.helpfulness_data_table.setHorizontalHeaderLabels(data_headers)
            for row_index in range(table_rows):
                self.helpfulness_data_table.setItem(
                    row_index, 0,
                    QtGui.QTableWidgetItem(
                        str(data["data"][row_index]["create_stamp"])))
                self.helpfulness_data_table.setItem(
                    row_index, 1,
                    QtGui.QTableWidgetItem(
                        str(data["data"][row_index]["entity_type"])))
                self.helpfulness_data_table.setItem(
                    row_index, 2,
                    QtGui.QTableWidgetItem(
                        str(data["data"][row_index]["entity_id"])))
                self.helpfulness_data_table.setItem(
                    row_index, 3,
                    QtGui.QTableWidgetItem(str(
                        data["data"][row_index]["FSN"])))
                self.helpfulness_data_table.setItem(
                    row_index, 4,
                    QtGui.QTableWidgetItem(
                        str(data["data"][row_index]["feedback"])))
                self.helpfulness_data_table.setItem(
                    row_index, 5,
                    QtGui.QTableWidgetItem(
                        str(data["data"][row_index]["metadata"])))
            self.helpfulness_data_table.setSortingEnabled(True)
            self.helpfulness_data_table.resizeColumnsToContents()
            self.helpfulness_data_table.setColumnWidth(5, 200)
            self.helpfulness_data_table.setWordWrap(True)
            self.helpfulness_data_table.resizeRowsToContents()
            self.alertMessage(
                "Completed!",
                "Finished summarizing feedback data for the selected entity types between %s and %s"
                % (self.start_date_edit.date().toPyDate(),
                   self.end_date_edit.date().toPyDate()))
        else:
            self.alertMessage(
                "No Data Available!",
                "There is no feedback available for the selected entity types between %s and %s"
                % (self.start_date_edit.date().toPyDate(),
                   self.end_date_edit.date().toPyDate()))

    def limitEndDate(self):
        self.end_date_edit.setMinimumDate(
            self.start_date_edit.date().toPyDate())

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)
Ejemplo n.º 10
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1327, 481)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.centralWidget.setObjectName("centralWidget")
        self.pushButton = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton.setGeometry(QtCore.QRect(10, 45, 202, 35))
        self.pushButton.setObjectName("pushButton")
        self.pbSwitchMap = QtWidgets.QPushButton(self.centralWidget)
        self.pbSwitchMap.setGeometry(QtCore.QRect(10, 131, 101, 35))
        self.pbSwitchMap.setObjectName("pbSwitchMap")
        self.groupBoxShowGeneral = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxShowGeneral.setGeometry(QtCore.QRect(11, 169, 91, 125))
        self.groupBoxShowGeneral.setAutoFillBackground(True)
        self.groupBoxShowGeneral.setObjectName("groupBoxShowGeneral")
        self.cbShowMarkers = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.cbShowMarkers.setGeometry(QtCore.QRect(10, 20, 70, 17))
        self.cbShowMarkers.setObjectName("cbShowMarkers")
        self.cbShowConnections = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.cbShowConnections.setGeometry(QtCore.QRect(10, 40, 81, 17))
        self.cbShowConnections.setObjectName("cbShowConnections")
        self.cbShowInfo = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.cbShowInfo.setGeometry(QtCore.QRect(10, 60, 81, 17))
        self.cbShowInfo.setObjectName("cbShowInfo")
        self.pbToggleBounce = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.pbToggleBounce.setGeometry(QtCore.QRect(10, 100, 71, 21))
        self.pbToggleBounce.setObjectName("pbToggleBounce")
        self.pbToggleHeatmap = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.pbToggleHeatmap.setGeometry(QtCore.QRect(10, 80, 71, 21))
        self.pbToggleHeatmap.setObjectName("pbToggleHeatmap")
        self.groupBoxShowNodes = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxShowNodes.setGeometry(QtCore.QRect(110, 170, 101, 124))
        self.groupBoxShowNodes.setAutoFillBackground(True)
        self.groupBoxShowNodes.setObjectName("groupBoxShowNodes")
        self.cbShowGood = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowGood.setGeometry(QtCore.QRect(10, 20, 70, 17))
        self.cbShowGood.setObjectName("cbShowGood")
        self.cbShowBad = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowBad.setGeometry(QtCore.QRect(10, 60, 70, 17))
        self.cbShowBad.setObjectName("cbShowBad")
        self.cbShowPing = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowPing.setGeometry(QtCore.QRect(10, 80, 71, 17))
        self.cbShowPing.setObjectName("cbShowPing")
        self.cbShowUnresolved = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowUnresolved.setGeometry(QtCore.QRect(10, 40, 81, 17))
        self.cbShowUnresolved.setObjectName("cbShowUnresolved")
        self.cbShowKilled = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowKilled.setGeometry(QtCore.QRect(10, 100, 71, 17))
        self.cbShowKilled.setObjectName("cbShowKilled")
        self.groupBoxStatusHosts = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxStatusHosts.setGeometry(QtCore.QRect(219, 40, 111, 38))
        self.groupBoxStatusHosts.setObjectName("groupBoxStatusHosts")
        self.labelHostsSolved = QtWidgets.QLabel(self.groupBoxStatusHosts)
        self.labelHostsSolved.setGeometry(QtCore.QRect(10, 15, 61, 16))
        self.labelHostsSolved.setObjectName("labelHostsSolved")
        self.statusHostsSolved = QtWidgets.QLabel(self.groupBoxStatusHosts)
        self.statusHostsSolved.setGeometry(QtCore.QRect(76, 13, 31, 20))
        self.statusHostsSolved.setObjectName("statusHostsSolved")
        self.groupBoxShowConnections = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxShowConnections.setGeometry(QtCore.QRect(
            11, 298, 91, 121))
        self.groupBoxShowConnections.setAutoFillBackground(True)
        self.groupBoxShowConnections.setObjectName("groupBoxShowConnections")
        self.cbShowGoodConn = QtWidgets.QCheckBox(self.groupBoxShowConnections)
        self.cbShowGoodConn.setGeometry(QtCore.QRect(10, 20, 70, 17))
        self.cbShowGoodConn.setObjectName("cbShowGoodConn")
        self.cbShowUnresolvedConn = QtWidgets.QCheckBox(
            self.groupBoxShowConnections)
        self.cbShowUnresolvedConn.setGeometry(QtCore.QRect(10, 40, 81, 17))
        self.cbShowUnresolvedConn.setObjectName("cbShowUnresolvedConn")
        self.cbShowBadConn = QtWidgets.QCheckBox(self.groupBoxShowConnections)
        self.cbShowBadConn.setGeometry(QtCore.QRect(10, 60, 70, 17))
        self.cbShowBadConn.setObjectName("cbShowBadConn")
        self.cbShowConnectionsActive = QtWidgets.QCheckBox(
            self.groupBoxShowConnections)
        self.cbShowConnectionsActive.setGeometry(QtCore.QRect(10, 80, 81, 17))
        self.cbShowConnectionsActive.setObjectName("cbShowConnectionsActive")
        self.cbShowKilledConn = QtWidgets.QCheckBox(
            self.groupBoxShowConnections)
        self.cbShowKilledConn.setGeometry(QtCore.QRect(10, 99, 81, 17))
        self.cbShowKilledConn.setObjectName("cbShowKilledConn")
        self.pbOpenFile = QtWidgets.QPushButton(self.centralWidget)
        self.pbOpenFile.setGeometry(QtCore.QRect(10, 88, 202, 35))
        self.pbOpenFile.setObjectName("pbOpenFile")
        self.groupBoxOptions = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxOptions.setGeometry(QtCore.QRect(110, 298, 101, 61))
        self.groupBoxOptions.setAutoFillBackground(True)
        self.groupBoxOptions.setObjectName("groupBoxOptions")
        self.cbPlot = QtWidgets.QCheckBox(self.groupBoxOptions)
        self.cbPlot.setGeometry(QtCore.QRect(10, 18, 70, 17))
        self.cbPlot.setChecked(False)
        self.cbPlot.setObjectName("cbPlot")
        self.cbSound = QtWidgets.QCheckBox(self.groupBoxOptions)
        self.cbSound.setGeometry(QtCore.QRect(10, 38, 70, 17))
        self.cbSound.setChecked(False)
        self.cbSound.setObjectName("cbSound")
        self.comboBoxInterface = QtWidgets.QComboBox(self.centralWidget)
        self.comboBoxInterface.setGeometry(QtCore.QRect(11, 7, 319, 31))
        self.comboBoxInterface.setObjectName("comboBoxInterface")
        self.groupBox = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox.setGeometry(QtCore.QRect(220, 262, 111, 97))
        self.groupBox.setAutoFillBackground(False)
        self.groupBox.setStyleSheet("background-color: rgb(255, 247, 211);")
        self.groupBox.setObjectName("groupBox")
        self.cbKillBad = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillBad.setGeometry(QtCore.QRect(10, 36, 70, 17))
        self.cbKillBad.setChecked(False)
        self.cbKillBad.setObjectName("cbKillBad")
        self.cbKillNone = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillNone.setGeometry(QtCore.QRect(10, 17, 70, 17))
        self.cbKillNone.setChecked(True)
        self.cbKillNone.setObjectName("cbKillNone")
        self.cbKillAll = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillAll.setGeometry(QtCore.QRect(10, 75, 70, 17))
        self.cbKillAll.setChecked(False)
        self.cbKillAll.setObjectName("cbKillAll")
        self.cbKillBandwidth = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillBandwidth.setGeometry(QtCore.QRect(10, 56, 91, 17))
        self.cbKillBandwidth.setChecked(False)
        self.cbKillBandwidth.setObjectName("cbKillBandwidth")
        self.groupBox_2 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_2.setGeometry(QtCore.QRect(219, 137, 111, 55))
        self.groupBox_2.setObjectName("groupBox_2")
        self.statusNodes = QtWidgets.QLabel(self.groupBox_2)
        self.statusNodes.setGeometry(QtCore.QRect(75, 14, 31, 20))
        self.statusNodes.setObjectName("statusNodes")
        self.labelConnections_2 = QtWidgets.QLabel(self.groupBox_2)
        self.labelConnections_2.setGeometry(QtCore.QRect(9, 16, 61, 16))
        self.labelConnections_2.setObjectName("labelConnections_2")
        self.statusBadNodes = QtWidgets.QLabel(self.groupBox_2)
        self.statusBadNodes.setGeometry(QtCore.QRect(75, 31, 31, 20))
        self.statusBadNodes.setObjectName("statusBadNodes")
        self.labelBadNodes = QtWidgets.QLabel(self.groupBox_2)
        self.labelBadNodes.setGeometry(QtCore.QRect(9, 33, 61, 16))
        self.labelBadNodes.setObjectName("labelBadNodes")
        self.groupBox_3 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_3.setGeometry(QtCore.QRect(220, 194, 111, 61))
        self.groupBox_3.setObjectName("groupBox_3")
        self.statusRxBytes = QtWidgets.QLabel(self.groupBox_3)
        self.statusRxBytes.setGeometry(QtCore.QRect(56, 34, 51, 20))
        self.statusRxBytes.setObjectName("statusRxBytes")
        self.labelRXBytes = QtWidgets.QLabel(self.groupBox_3)
        self.labelRXBytes.setGeometry(QtCore.QRect(10, 36, 41, 16))
        self.labelRXBytes.setObjectName("labelRXBytes")
        self.labelTXBytes = QtWidgets.QLabel(self.groupBox_3)
        self.labelTXBytes.setGeometry(QtCore.QRect(10, 15, 41, 16))
        self.labelTXBytes.setObjectName("labelTXBytes")
        self.statusTxBytes = QtWidgets.QLabel(self.groupBox_3)
        self.statusTxBytes.setGeometry(QtCore.QRect(56, 13, 51, 20))
        self.statusTxBytes.setObjectName("statusTxBytes")
        self.groupBox_4 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_4.setGeometry(QtCore.QRect(219, 80, 111, 55))
        self.groupBox_4.setObjectName("groupBox_4")
        self.statusConnections = QtWidgets.QLabel(self.groupBox_4)
        self.statusConnections.setGeometry(QtCore.QRect(75, 12, 31, 20))
        self.statusConnections.setObjectName("statusConnections")
        self.labelConnections = QtWidgets.QLabel(self.groupBox_4)
        self.labelConnections.setGeometry(QtCore.QRect(9, 14, 61, 16))
        self.labelConnections.setObjectName("labelConnections")
        self.labelKilledNodes = QtWidgets.QLabel(self.groupBox_4)
        self.labelKilledNodes.setGeometry(QtCore.QRect(10, 31, 60, 16))
        self.labelKilledNodes.setObjectName("labelKilledNodes")
        self.statusKilledNodes = QtWidgets.QLabel(self.groupBox_4)
        self.statusKilledNodes.setGeometry(QtCore.QRect(75, 31, 30, 20))
        self.statusKilledNodes.setObjectName("statusKilledNodes")
        self.listWidgetKilledProcesses = QtWidgets.QListWidget(
            self.centralWidget)
        self.listWidgetKilledProcesses.setGeometry(
            QtCore.QRect(338, 23, 131, 161))
        self.listWidgetKilledProcesses.setObjectName(
            "listWidgetKilledProcesses")
        self.label = QtWidgets.QLabel(self.centralWidget)
        self.label.setGeometry(QtCore.QRect(339, 3, 91, 16))
        self.label.setObjectName("label")
        self.listWidgetNodes = QtWidgets.QListWidget(self.centralWidget)
        self.listWidgetNodes.setGeometry(QtCore.QRect(477, 23, 531, 447))
        self.listWidgetNodes.setObjectName("listWidgetNodes")
        self.label_2 = QtWidgets.QLabel(self.centralWidget)
        self.label_2.setGeometry(QtCore.QRect(478, 4, 91, 16))
        self.label_2.setObjectName("label_2")
        self.pbGenerateReport = QtWidgets.QPushButton(self.centralWidget)
        self.pbGenerateReport.setGeometry(QtCore.QRect(530, 2, 161, 21))
        self.pbGenerateReport.setStyleSheet(
            "background-color: rgb(225, 229, 255);")
        self.pbGenerateReport.setObjectName("pbGenerateReport")
        self.groupBoxPing = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxPing.setGeometry(QtCore.QRect(338, 298, 131, 121))
        self.groupBoxPing.setTitle("")
        self.groupBoxPing.setObjectName("groupBoxPing")
        self.cbPingIP = QtWidgets.QRadioButton(self.groupBoxPing)
        self.cbPingIP.setGeometry(QtCore.QRect(90, 43, 31, 17))
        self.cbPingIP.setChecked(True)
        self.cbPingIP.setObjectName("cbPingIP")
        self.cbPingAll = QtWidgets.QRadioButton(self.groupBoxPing)
        self.cbPingAll.setGeometry(QtCore.QRect(10, 43, 81, 17))
        self.cbPingAll.setChecked(False)
        self.cbPingAll.setObjectName("cbPingAll")
        self.pbPing = QtWidgets.QPushButton(self.groupBoxPing)
        self.pbPing.setGeometry(QtCore.QRect(9, 92, 113, 24))
        self.pbPing.setObjectName("pbPing")
        self.groupBox_5 = QtWidgets.QGroupBox(self.groupBoxPing)
        self.groupBox_5.setGeometry(QtCore.QRect(0, -4, 131, 25))
        self.groupBox_5.setTitle("")
        self.groupBox_5.setObjectName("groupBox_5")
        self.cbPingAuto = QtWidgets.QCheckBox(self.groupBox_5)
        self.cbPingAuto.setGeometry(QtCore.QRect(86, 5, 41, 17))
        self.cbPingAuto.setChecked(True)
        self.cbPingAuto.setObjectName("cbPingAuto")
        self.comboPing = QtWidgets.QComboBox(self.groupBoxPing)
        self.comboPing.setGeometry(QtCore.QRect(10, 65, 111, 22))
        self.comboPing.setObjectName("comboPing")
        self.cbPingRandom = QtWidgets.QRadioButton(self.groupBoxPing)
        self.cbPingRandom.setGeometry(QtCore.QRect(10, 25, 121, 17))
        self.cbPingRandom.setChecked(False)
        self.cbPingRandom.setObjectName("cbPingRandom")
        self.label_3 = QtWidgets.QLabel(self.centralWidget)
        self.label_3.setGeometry(QtCore.QRect(349, 298, 81, 16))
        self.label_3.setObjectName("label_3")
        self.groupBox_6 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_6.setGeometry(QtCore.QRect(339, 189, 131, 101))
        self.groupBox_6.setStyleSheet("background-color: rgb(255, 247, 211);")
        self.groupBox_6.setObjectName("groupBox_6")
        self.comboKill = QtWidgets.QComboBox(self.groupBox_6)
        self.comboKill.setGeometry(QtCore.QRect(10, 43, 113, 22))
        self.comboKill.setObjectName("comboKill")
        self.pbKill = QtWidgets.QPushButton(self.groupBox_6)
        self.pbKill.setGeometry(QtCore.QRect(9, 72, 113, 24))
        self.pbKill.setObjectName("pbKill")
        self.cbKillAllNow = QtWidgets.QRadioButton(self.groupBox_6)
        self.cbKillAllNow.setGeometry(QtCore.QRect(10, 20, 41, 17))
        self.cbKillAllNow.setChecked(False)
        self.cbKillAllNow.setObjectName("cbKillAllNow")
        self.cbKillIP = QtWidgets.QRadioButton(self.groupBox_6)
        self.cbKillIP.setGeometry(QtCore.QRect(91, 20, 31, 17))
        self.cbKillIP.setChecked(True)
        self.cbKillIP.setObjectName("cbKillIP")
        self.cbKillBadNow = QtWidgets.QRadioButton(self.groupBox_6)
        self.cbKillBadNow.setGeometry(QtCore.QRect(50, 20, 41, 17))
        self.cbKillBadNow.setChecked(False)
        self.cbKillBadNow.setObjectName("cbKillBadNow")
        self.groupBox_7 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_7.setGeometry(QtCore.QRect(110, 368, 221, 51))
        self.groupBox_7.setStyleSheet("background-color: rgb(255, 247, 211);")
        self.groupBox_7.setObjectName("groupBox_7")
        self.cbBlockBadInFirewall = QtWidgets.QCheckBox(self.groupBox_7)
        self.cbBlockBadInFirewall.setGeometry(QtCore.QRect(8, 19, 211, 17))
        self.cbBlockBadInFirewall.setChecked(False)
        self.cbBlockBadInFirewall.setObjectName("cbBlockBadInFirewall")
        self.ptSelectedIP = QtWidgets.QPlainTextEdit(self.centralWidget)
        self.ptSelectedIP.setEnabled(True)
        self.ptSelectedIP.setGeometry(QtCore.QRect(1016, 23, 301, 447))
        self.ptSelectedIP.setToolTip("")
        self.ptSelectedIP.setObjectName("ptSelectedIP")
        self.cbAutoScrollNodes = QtWidgets.QCheckBox(self.centralWidget)
        self.cbAutoScrollNodes.setGeometry(QtCore.QRect(700, 3, 70, 17))
        self.cbAutoScrollNodes.setChecked(True)
        self.cbAutoScrollNodes.setObjectName("cbAutoScrollNodes")
        self.groupBox_8 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_8.setGeometry(QtCore.QRect(11, 420, 458, 51))
        self.groupBox_8.setObjectName("groupBox_8")
        self.comboShowHost = CheckableComboBox(self.centralWidget)
        self.comboShowHost.setGeometry(QtCore.QRect(20, 439, 439, 22))
        self.comboShowHost.setObjectName("comboShowHost")
        self.lblStatus = QtWidgets.QLabel(self.centralWidget)
        self.lblStatus.setGeometry(QtCore.QRect(1301, 1, 16, 20))
        self.lblStatus.setToolTip("")
        self.lblStatus.setToolTipDuration(-1)
        self.lblStatus.setStatusTip("")
        self.lblStatus.setStyleSheet("")
        self.lblStatus.setObjectName("lblStatus")
        self.label_4 = QtWidgets.QLabel(self.centralWidget)
        self.label_4.setGeometry(QtCore.QRect(1256, 2, 41, 16))
        self.label_4.setToolTip("")
        self.label_4.setToolTipDuration(5)
        self.label_4.setObjectName("label_4")
        self.statusHostsRequested = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsRequested.setGeometry(QtCore.QRect(280, 500, 31, 20))
        self.statusHostsRequested.setObjectName("statusHostsRequested")
        self.labelHostsRequested = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsRequested.setGeometry(QtCore.QRect(214, 502, 61, 16))
        self.labelHostsRequested.setObjectName("labelHostsRequested")
        self.statusHostsFailed = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsFailed.setGeometry(QtCore.QRect(280, 530, 31, 20))
        self.statusHostsFailed.setObjectName("statusHostsFailed")
        self.labelHostsFailed = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsFailed.setGeometry(QtCore.QRect(214, 532, 61, 16))
        self.labelHostsFailed.setObjectName("labelHostsFailed")
        self.statusHostsFailedOld = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsFailedOld.setGeometry(QtCore.QRect(280, 560, 31, 20))
        self.statusHostsFailedOld.setObjectName("statusHostsFailedOld")
        self.labelHostsFailedOld = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsFailedOld.setGeometry(QtCore.QRect(214, 562, 61, 16))
        self.labelHostsFailedOld.setObjectName("labelHostsFailedOld")
        self.statusHostsResolvedOld = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsResolvedOld.setGeometry(QtCore.QRect(280, 590, 31, 20))
        self.statusHostsResolvedOld.setObjectName("statusHostsResolvedOld")
        self.labelHostsResolvedOld = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsResolvedOld.setGeometry(QtCore.QRect(214, 592, 61, 16))
        self.labelHostsResolvedOld.setObjectName("labelHostsResolvedOld")
        self.pbShowMap = QtWidgets.QPushButton(self.centralWidget)
        self.pbShowMap.setGeometry(QtCore.QRect(111, 131, 101, 35))
        self.pbShowMap.setStyleSheet("background-color: rgb(225, 229, 255);")
        self.pbShowMap.setObjectName("pbShowMap")
        self.pbStartIpNetInfo = QtWidgets.QPushButton(self.centralWidget)
        self.pbStartIpNetInfo.setGeometry(QtCore.QRect(1015, 2, 101, 21))
        self.pbStartIpNetInfo.setStyleSheet(
            "background-color: rgb(225, 229, 255);")
        self.pbStartIpNetInfo.setObjectName("pbStartIpNetInfo")
        self.groupBox_9 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_9.setGeometry(QtCore.QRect(1120, 2, 101, 21))
        self.groupBox_9.setTitle("")
        self.groupBox_9.setObjectName("groupBox_9")
        self.rbAllIpInfos = QtWidgets.QRadioButton(self.groupBox_9)
        self.rbAllIpInfos.setGeometry(QtCore.QRect(5, 2, 31, 17))
        self.rbAllIpInfos.setChecked(True)
        self.rbAllIpInfos.setObjectName("rbAllIpInfos")
        self.rbSelectedIpInfos = QtWidgets.QRadioButton(self.groupBox_9)
        self.rbSelectedIpInfos.setGeometry(QtCore.QRect(39, 2, 61, 17))
        self.rbSelectedIpInfos.setObjectName("rbSelectedIpInfos")
        MainWindow.setCentralWidget(self.centralWidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "IPRadar2"))
        self.pushButton.setText(_translate("MainWindow", "live capture"))
        self.pbSwitchMap.setText(_translate("MainWindow", "switch map"))
        self.groupBoxShowGeneral.setTitle(
            _translate("MainWindow", "Show general"))
        self.cbShowMarkers.setText(_translate("MainWindow", "nodes"))
        self.cbShowConnections.setText(_translate("MainWindow", "connections"))
        self.cbShowInfo.setText(_translate("MainWindow", "info marker"))
        self.pbToggleBounce.setText(_translate("MainWindow", "bounce"))
        self.pbToggleHeatmap.setText(_translate("MainWindow", "heatmap"))
        self.groupBoxShowNodes.setTitle(_translate("MainWindow", "Show nodes"))
        self.cbShowGood.setText(_translate("MainWindow", "good"))
        self.cbShowBad.setText(_translate("MainWindow", "bad"))
        self.cbShowPing.setText(_translate("MainWindow", "ping neg."))
        self.cbShowUnresolved.setText(_translate("MainWindow", "unresolved"))
        self.cbShowKilled.setText(_translate("MainWindow", "killed"))
        self.groupBoxStatusHosts.setTitle(
            _translate("MainWindow", "Whos IP infos:"))
        self.labelHostsSolved.setText(_translate("MainWindow", "resolved:"))
        self.statusHostsSolved.setText(_translate("MainWindow", "0"))
        self.groupBoxShowConnections.setTitle(
            _translate("MainWindow", "Show conn.\'s"))
        self.cbShowGoodConn.setText(_translate("MainWindow", "good"))
        self.cbShowUnresolvedConn.setText(
            _translate("MainWindow", "unresolved"))
        self.cbShowBadConn.setText(_translate("MainWindow", "bad"))
        self.cbShowConnectionsActive.setText(
            _translate("MainWindow", "active conn."))
        self.cbShowKilledConn.setText(_translate("MainWindow", "killed"))
        self.pbOpenFile.setText(_translate("MainWindow", "open file"))
        self.groupBoxOptions.setTitle(_translate("MainWindow", "Options"))
        self.cbPlot.setText(_translate("MainWindow", "plot"))
        self.cbSound.setText(_translate("MainWindow", "sound"))
        self.groupBox.setTitle(_translate("MainWindow",
                                          "Kill conn.\'s (auto)"))
        self.cbKillBad.setText(_translate("MainWindow", "bad"))
        self.cbKillNone.setText(_translate("MainWindow", "none"))
        self.cbKillAll.setText(_translate("MainWindow", "all"))
        self.cbKillBandwidth.setText(
            _translate("MainWindow", "bandwidth limit"))
        self.groupBox_2.setTitle(_translate("MainWindow", "Nodes"))
        self.statusNodes.setText(_translate("MainWindow", "0"))
        self.labelConnections_2.setText(_translate("MainWindow", "total:"))
        self.statusBadNodes.setText(_translate("MainWindow", "0"))
        self.labelBadNodes.setText(_translate("MainWindow", "bad:"))
        self.groupBox_3.setTitle(_translate("MainWindow", "Data"))
        self.statusRxBytes.setText(_translate("MainWindow", "0"))
        self.labelRXBytes.setText(_translate("MainWindow", "RX [KB]:"))
        self.labelTXBytes.setText(_translate("MainWindow", "TX [KB]:"))
        self.statusTxBytes.setText(_translate("MainWindow", "0"))
        self.groupBox_4.setTitle(_translate("MainWindow", "Connections"))
        self.statusConnections.setText(_translate("MainWindow", "0"))
        self.labelConnections.setText(_translate("MainWindow", "current:"))
        self.labelKilledNodes.setText(_translate("MainWindow", "killed:"))
        self.statusKilledNodes.setText(_translate("MainWindow", "0"))
        self.label.setText(_translate("MainWindow", "Killed processes"))
        self.label_2.setText(_translate("MainWindow", "Nodes"))
        self.pbGenerateReport.setText(
            _translate("MainWindow", "create report_DATE.csv"))
        self.cbPingIP.setText(_translate("MainWindow", "IP:"))
        self.cbPingAll.setText(_translate("MainWindow", "all known"))
        self.pbPing.setText(_translate("MainWindow", "ping"))
        self.cbPingAuto.setText(_translate("MainWindow", "auto"))
        self.cbPingRandom.setText(_translate("MainWindow", "10 random IPs"))
        self.label_3.setText(_translate("MainWindow", "Ping Command"))
        self.groupBox_6.setTitle(
            _translate("MainWindow", "Kill active conn.\'s Cmd"))
        self.pbKill.setText(_translate("MainWindow", "kill"))
        self.cbKillAllNow.setText(_translate("MainWindow", "all"))
        self.cbKillIP.setText(_translate("MainWindow", "IP:"))
        self.cbKillBadNow.setText(_translate("MainWindow", "bad"))
        self.groupBox_7.setTitle(_translate("MainWindow",
                                            "Firewall (Windows)"))
        self.cbBlockBadInFirewall.setText(
            _translate("MainWindow",
                       "add rule to block \"bad\" IPs automatically"))
        self.cbAutoScrollNodes.setText(_translate("MainWindow", "auto-scroll"))
        self.groupBox_8.setTitle(
            _translate("MainWindow", "Show selected owners"))
        self.lblStatus.setText(_translate("MainWindow", "*"))
        self.label_4.setText(_translate("MainWindow", "status: "))
        self.statusHostsRequested.setText(_translate("MainWindow", "0"))
        self.labelHostsRequested.setText(
            _translate("MainWindow", "requested: "))
        self.statusHostsFailed.setText(_translate("MainWindow", "0"))
        self.labelHostsFailed.setText(_translate("MainWindow", "failed:"))
        self.statusHostsFailedOld.setText(_translate("MainWindow", "0"))
        self.labelHostsFailedOld.setText(
            _translate("MainWindow", "failed (past):"))
        self.statusHostsResolvedOld.setText(_translate("MainWindow", "0"))
        self.labelHostsResolvedOld.setText(
            _translate("MainWindow", "resol. (past):"))
        self.pbShowMap.setText(_translate("MainWindow", "show map"))
        self.pbStartIpNetInfo.setText(_translate("MainWindow", "ipnetinfo"))
        self.rbAllIpInfos.setText(_translate("MainWindow", "all"))
        self.rbSelectedIpInfos.setText(_translate("MainWindow", "selected"))
Ejemplo n.º 11
0
class LeaveApproval(QtGui.QWidget):
    def __init__(self, user_id, password, *args, **kwargs):
        super(LeaveApproval, self).__init__(*args, **kwargs)
        self.user_id, self.password = user_id, password
        self.work_calendar = None
        self.selected_name = False
        self.createUI()
        self.initiate()
        self.mapEvents()
        self.applyFilters()


    def createUI(self):
        self.date_label = QtGui.QLabel("Date(s):")
        self.start_date = FormattedDateEdit()
        self.end_date = FormattedDateEdit()

        self.employees_label = QtGui.QLabel("Employees:")
        self.employees_selection_box = CheckableComboBox("Employees")
        self.all_button = QtGui.QPushButton("Select All")
        self.clear_button = QtGui.QPushButton("Clear")

        self.refresh_table_button = QtGui.QPushButton("Refresh Table")
        self.approve_selected_button = QtGui.QPushButton("Approved")
        self.approve_selected_button.setCheckable(True)
        self.reject_selected_button = QtGui.QPushButton("Rejected")
        self.reject_selected_button.setCheckable(True)
        self.pending_selected_button = QtGui.QPushButton("Pending")
        self.pending_selected_button.setCheckable(True)

        self.button_group = QtGui.QButtonGroup()
        self.button_group.addButton(self.approve_selected_button)
        self.button_group.addButton(self.reject_selected_button)
        self.button_group.addButton(self.pending_selected_button)
        self.button_group.setExclusive(True)

        self.approval_comment_label = QtGui.QLabel("Approval\\Rejection Comment:")
        self.rejection_comment_lineedit = QtGui.QLineEdit()

        self.leave_table = CopiableQTableWidget(0, 0)

        self.status_label = QtGui.QLabel("Status")
        self.status_combobox = QtGui.QComboBox()
        self.status_combobox.addItems(["Working","Leave"])
        self.comment_label = QtGui.QLabel("Comment")
        self.comment_lineedit = QtGui.QLineEdit()
        self.save_selected_button = QtGui.QPushButton("Save")
        self.save_selected_button.setEnabled(False)
        self.save_all_button = QtGui.QPushButton("Save All")

        row_1 = QtGui.QHBoxLayout()
        row_1.addWidget(self.date_label,0)
        row_1.addWidget(self.start_date,0)
        row_1.addWidget(self.end_date,0)
        row_1.addWidget(self.employees_label,0)
        row_1.addWidget(self.employees_selection_box,0)
        row_1.addWidget(self.all_button,0)
        row_1.addWidget(self.clear_button,0)

        self.relaxation_label = QtGui.QLabel("Relaxation")
        self.relaxation_spinbox = QtGui.QDoubleSpinBox()
        self.relaxation_spinbox.setSuffix("%")

        row_2 = QtGui.QHBoxLayout()
        row_2.addWidget(self.status_label, 0)
        row_2.addWidget(self.status_combobox, 0)
        row_2.addWidget(self.relaxation_label, 0)
        row_2.addWidget(self.relaxation_spinbox, 0)
        row_2.addWidget(self.comment_label, 0)
        row_2.addWidget(self.comment_lineedit, 0)

        row_3 = QtGui.QHBoxLayout()
        row_3.addWidget(self.approval_comment_label,0)
        row_3.addWidget(self.rejection_comment_lineedit,0)
        row_3.addWidget(self.approve_selected_button,0)
        row_3.addWidget(self.reject_selected_button,0)
        row_3.addWidget(self.pending_selected_button,0)
        row_3.addWidget(self.save_selected_button,0)
        row_3.addWidget(self.save_all_button,0)
        row_3.addWidget(self.refresh_table_button,0)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_1)
        layout.addLayout(row_2)
        layout.addLayout(row_3)
        layout.addWidget(self.leave_table)

        self.setLayout(layout)
        self.setWindowTitle("Leaves Manager")
        self.setWindowIcon(QtGui.QIcon(os.path.join(MOSES.getPathToImages(),"PORK_Icon.png")))
        self.show()

    def mapEvents(self):
        self.start_date.dateChanged.connect(self.startDateChanged)
        self.end_date.dateChanged.connect(self.applyFilters)
        self.refresh_table_button.clicked.connect(self.applyFilters)
        self.clear_button.clicked.connect(self.employees_selection_box.clearSelection)
        self.leave_table.currentCellChanged.connect(self.populateForm)
        self.employees_selection_box.changedSelection.connect(self.applyFilters)
        self.save_selected_button.clicked.connect(self.saveSelected)
        self.save_all_button.clicked.connect(self.saveAll)
        self.all_button.clicked.connect(self.employees_selection_box.selectAll)

    def saveSelected(self):
        if self.selected_name:
            self.saveThese([self.selected_name])
        else:
            self.alertMessage("Select a row","Select a row in the work calendar and then try again.")
            self.save_selected_button.setEnabled(False)

    def saveAll(self):
        self.saveThese(self.employees_selection_box.getCheckedItems())


    def saveThese(self, selected_names):
        selected_employee_ids = [list(self.employees_list[self.employees_list["Name"] == x]["Employee ID"])[0] for x in selected_names]
        dates = [self.start_date.date().toPyDate(), self.end_date.date().toPyDate()]
        allow_continue = False
        if (len(selected_employee_ids)>1) and (dates[0] == dates[1]):
            ask = QtGui.QMessageBox.question(self, 'Multiple Employees Selected!', "You appear to have chosen the ids of several employees. Click yes if you'd like to continue modifying the work calendar for all their names. If not, click no and select only one employee's name.", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
            if ask == QtGui.QMessageBox.Yes:
                allow_continue = True
        elif (len(selected_employee_ids) > 1) and (dates[0] < dates[1]):
            ask = QtGui.QMessageBox.question(self, 'Multiple Dates and Employees Selected!', "You appear to have chosen the ids of several employees and an entire date range. Are you sure that you want to apply the settings for all of them for all these dates? I'd recommend changing the status of one employee for one date at a time. Click yes if you'd like to continue modifying the work calendar for all their names for those dates. If not, click no and select only one employee's name and one date.", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
            if ask == QtGui.QMessageBox.Yes:
                allow_continue = True
        elif (len(selected_employee_ids) == 1) and (dates[0] < dates[1]):
            ask = QtGui.QMessageBox.question(self, 'Multiple Dates Selected!', "You appear to have chosen an entire date range. Are you sure that you want to apply the settings for the selected employee all these dates? I'd recommend changing the status of one employee for one date at a time. Click yes if you'd like to continue modifying the work calendar for all their names for those dates. If not, click no and select only one date.", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
            if ask == QtGui.QMessageBox.Yes:
                allow_continue = True
        elif (len(selected_employee_ids) <= 0):
            self.alertMessage('No Employees Selected!', "Please select an employee in order to process the work status and relaxation.")
        else:
            allow_continue = True

        if allow_continue:
            status = str(self.status_combobox.currentText())
            relaxation = self.relaxation_spinbox.value()/100
            comment = str(self.comment_lineedit.text())
            if self.approve_selected_button.isChecked():
                approval = "Approved"
            elif self.reject_selected_button.isChecked():
                approval = "Rejected"
            else:
                approval = "Pending"
            approval_comment = str(self.rejection_comment_lineedit.text())
            self.alertMessage("Please Wait","This could take a while. Click OK and hold on to your horses.")
            update = MOSES.updateWorkCalendarFor(self.user_id, self.password, status, relaxation, comment, approval, approval_comment, dates, selected_employee_ids)
            if update:
                self.alertMessage("Success","Successfully updated the Work Calendar")
                self.applyFilters()
            else:
                self.alertMessage("Failure","Failed in updating the Work Calendar")

        else:
            print "Not allowed to continue"

    def initiate(self):
        self.start_date.setDate(datetime.date.today())
        self.start_date.setMinimumDate(datetime.date(2015,1,1))
        self.end_date.setDate(self.start_date.date())
        self.end_date.setMinimumDate(self.start_date.date())
        self.employees_list = MOSES.getEmployeesList(self.user_id, self.password, self.end_date.date().toPyDate())
        self.employees_selection_box.clear()
        self.employees_selection_box.addItems(sorted(list(self.employees_list["Name"])))
        self.employees_selection_box.selectAll()

    def applyFilters(self):
        self.leave_table.showDataFrame(None)
        selected_employee_ids = [list(self.employees_list[self.employees_list["Name"] == x]["Employee ID"])[0] for x in self.employees_selection_box.getCheckedItems()]
        if len(selected_employee_ids)<=0:
            self.alertMessage("No Employees Selected","Select at least one employee!")
        else:
            filter_dict = {
                            "Dates": [self.start_date.date().toPyDate(), self.end_date.date().toPyDate()],
                            "Employee IDs": selected_employee_ids
                        }
            time_diff = (filter_dict["Dates"][1] - filter_dict["Dates"][0])
            if datetime.timedelta(days=5) < time_diff < datetime.timedelta(days=30):
                self.alertMessage("Please Wait","The work calendar is being refreshed. This may take a while since you've selected over a week's worth of data.")
            elif time_diff >= datetime.timedelta(days=30):
                self.alertMessage("Please Wait","The work calendar is being refreshed. This will take quite some time longer than usual since you've selected a date range wider than or equal to 30 days.")

            
            self.work_calendar = MOSES.getWorkCalendarFor(self.user_id, self.password, filter_dict)
            self.alertMessage("Success","Retrieved the Work Calendar")
            yellow = QtGui.QColor(200,200,0)
            green = QtGui.QColor(0,153,0)
            red = QtGui.QColor(170,0,0)

            highlight_rules = [
                                {
                                    "Columns": ["Status","Approval"],
                                    "Values": ["Leave","Approved"],
                                    "Color":green
                                },
                                {
                                    "Columns": ["Status","Approval"],
                                    "Values": ["Leave","Pending"],
                                    "Color":  yellow
                                },
                                {
                                    "Columns": ["Status","Approval"],
                                    "Values": ["Leave","Rejected"],
                                    "Color": red
                                },
                                {
                                    "Columns": ["Relaxation","Approval"],
                                    "Values": [[0.01,1.00],"Approved"],
                                    "Color": green
                                },
                                {
                                    "Columns": ["Relaxation","Approval"],
                                    "Values": [[0.01,1.00],"Pending"],
                                    "Color":  yellow
                                },
                                {
                                    "Columns": ["Relaxation","Approval"],
                                    "Values": [[0.01,1.00],"Rejected"],
                                    "Color": red
                                }
                                ]
            self.leave_table.showDataFrame(self.work_calendar,highlight_rules)
            self.leave_table.setSortingEnabled(False)

    def startDateChanged(self):
        self.end_date.setDate(self.start_date.date())
        self.end_date.setMinimumDate(self.start_date.date())
        self.applyFilters()

    def populateForm(self, row=None, column=None):
        if self.work_calendar is not None:
            #rows = sorted(set(index.row() for index in self.leave_table.selectedIndexes()))
            try:
                selected_row = self.work_calendar.loc[row]
                self.selected_name = selected_row["Employee Name"]
                status = selected_row["Status"]
                relaxation = selected_row["Relaxation"]
                comment = selected_row["Comment"]
                approval = selected_row["Approval"]
                rejection_comment = selected_row["Rejection Comment"]
                date_ = selected_row["Date"]
                self.save_selected_button.setText("Save %s's entry"%self.selected_name)
                self.save_selected_button.setEnabled(True)
            except:
                self.selected_name = None
                self.save_selected_button.setText("Save Selected")
                self.save_selected_button.setEnabled(False)
                comment = ""
                relaxation = 0.0
                rejection_comment = ""
                status = "Working"
                approval = "Pending"

            self.comment_lineedit.setText(comment if comment is not None else "")
            self.status_combobox.setCurrentIndex(self.status_combobox.findText(status))
            self.rejection_comment_lineedit.setText(rejection_comment if rejection_comment is not None else "")
            self.relaxation_spinbox.setValue((relaxation*100))
            if approval is not None:
                if approval == "Approved":
                    self.approve_selected_button.setChecked(True)
                elif approval == "Rejected":
                    self.reject_selected_button.setChecked(True)
                else:
                    self.pending_selected_button.setChecked(True)
            else:
                print "Approval is None!"

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)
Ejemplo n.º 12
0
class PiggyBankWithFilter(QtGui.QWidget):
    def __init__(self, user_id, password, category_tree=None, brands=None):
        super(PiggyBankWithFilter, self).__init__()
        self.user_id, self.password = user_id, password
        if category_tree is not None:
            self.category_tree = category_tree
        else:
            self.category_tree = MOSES.getCategoryTree(self.user_id, self.password)
        if brands is None:
            print "Pulling Brand list in PiggyBankWithFilter"
            self.brands = MOSES.getBrandValues(self.user_id, self.password)
        else:
            self.brands = brands
        self.createUI()
        self.piggybank_data = []
        self.mapEvents()
        self.changePage()
        self.populateBrand()
        self.populateWriters()
        self.show()


    def createUI(self):
        self.instruction_label = QtGui.QLabel("<b>Select filters from the following:</b>")

        self.writers_filter_box = CheckableComboBox("Writers")
        self.writers_filter_box.setToolTip("Select the writers whose data you'd like to extract.")

        self.category_selector = CategorySelector(self.category_tree)

        self.brands_filter_box = CheckableComboBox("Brands")
        self.brands_filter_box.setToolTip("Select the Brands you'd like to extract.")

        self.start_date_edit = QtGui.QDateTimeEdit()
        self.start_date_edit.setToolTip("Select the start date for the data set you'd like to extract.")
        self.start_date_edit.setCalendarPopup(True)
        self.start_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.start_date_edit.setMinimumDate(QtCore.QDate(2015,1,1))
        
        lwd = MOSES.getLastWorkingDate(self.user_id, self.password, queryUser="******")
        self.start_date_edit.setDate(lwd)

        self.end_date_edit = QtGui.QDateTimeEdit()
        self.end_date_edit.setToolTip("Select the End Date for the data set you'd like to extract.")
        self.end_date_edit.setDate(QtCore.QDate(datetime.date.today()))
        self.end_date_edit.setCalendarPopup(True)
        self.end_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.end_date_edit.setMinimumDate(self.start_date_edit.date().toPyDate())
        self.end_date_edit.setMaximumDate(datetime.date.today())
        self.end_date_edit.setDate(lwd)

        self.all_time_dates = QtGui.QCheckBox("Pull All Time Data")
        self.all_time_dates.setToolTip("Check this box to pull data for the selected filter from all available data.")

        self.piggybank_summarizer = PiggyBankSummarizer()
        self.piggybank_summarizer.setToolTip("This widget can be used to summarize the piggybank in various ways.")
        self.piggybank_summarizer.setEnabled(False)

        self.piggybank = CopiableQTableWidget(0,0)
        self.piggybank.setToolTip("This table shows all available data for the selected filters.")
        self.piggybank.setStyleSheet("gridline-color: rgb(0, 0, 0)")


        self.piggybank_summary_widget = QtGui.QWidget()
        self.piggybank_summary_column_chooser_label = QtGui.QLabel("Select Column(s):")
        self.piggybank_summary_column_chooser = CheckableComboBox("Columns")
        self.piggybank_summary_column_chooser.setToolTip("Select the piggy bank columns you'd like to summarize.")
        self.piggybank_summary_column_chooser.addItems(["Writer Name","Source", "Description Type", "BU","Super-Category", "Category", "Sub-Category", "Vertical", "Brand"])
        self.piggybank_summary_refresh_button = QtGui.QPushButton("Refresh Summary Table")
        self.piggybank_summary_refresh_button.setToolTip("Click this button to recalculate the audit plan and break up for the selected parameters.")
        
        self.piggybank_summary = CopiableQTableWidget(0,0)
        self.piggybank_summary.setToolTip("This table displays a break up of all the available data between the selected dates, for the chosen filters,\nbased on the summarization columns you've picked.")
        self.piggybank_summary.setStyleSheet("gridline-color: rgb(0, 0, 0)")

        self.piggybank_summary_random_fsns = CopiableQTableWidget(0,0)
        self.piggybank_summary_random_fsns.setToolTip("This table displays a list of random FSNs each editor must audit to satisfy his or her requirements for the selected duration.")
        self.piggybank_summary_random_fsns.setStyleSheet("gridline-color: rgb(0, 0, 0)")
        self.piggybank_summary_editor_summary = CopiableQTableWidget(0,0)
        self.piggybank_summary_editor_summary.setStyleSheet("gridline-color: rgb(0, 0, 0)")
        self.piggybank_summary_audit_percentage_label = QtGui.QLabel("Audit Percentage:")
        self.piggybank_summary_audit_percentage = QtGui.QSpinBox()
        self.piggybank_summary_audit_percentage.setToolTip("This shows the audit percentage for the selected editor(s).")
        self.piggybank_summary_audit_percentage.setRange(0,100)
        self.piggybank_summary_audit_percentage.setSuffix("%")
        self.piggybank_summary_editors_label = QtGui.QLabel("Editor:")
        self.piggybank_summary_editors_list = QtGui.QComboBox()
        self.piggybank_summary_editors_list.setToolTip("Select an editor to display his or her constraints for the chosen time frame.")
        self.piggybank_summary_editors_list.setToolTip("Select an editor to view his or her constraints.")
        self.resetEditorConstraints()
        editors_list = self.editor_audit_constraints.keys()
        editors_list.sort()
        self.piggybank_summary_editors_list.addItems(editors_list)
        self.piggybank_summary_editors_equality_checkbox = QtGui.QCheckBox("Use Equal Targets For All Editors")
        self.piggybank_summary_editors_equality_checkbox.setToolTip("When checked, this nullifies all the personal constraints for editors and treats them equally.\nThis is enabled by default when you purposely remove writer names' from the columns filter.\nUse this when calibrating.")
        self.piggybank_summary_editors_equality_checkbox.setCheckState(False)
        self.piggybank_summary_editor_utilization_label = QtGui.QLabel("Editor Utilization:")
        self.piggybank_summary_editor_utilization = QtGui.QDoubleSpinBox()
        self.piggybank_summary_editor_utilization.setToolTip("Set a utilization factor here.\n1.0 indicates 100%% for a duration of 1 day. If there are multiple working dates selected, then the utilization changes accordingly.\nNote: This doesn't accomodate for leaves taken by editors as of this version.")
        self.piggybank_summary_editor_utilization.setRange(0,3000.0)
        self.piggybank_summary_editor_utilization.setSingleStep(0.05)
        self.piggybank_summary_editor_minimum_wc_label = QtGui.QLabel("Minimum Word Count:")
        self.piggybank_summary_editor_minimum_wc = QtGui.QSpinBox()
        self.piggybank_summary_editor_minimum_wc.setRange(0,5000)
        self.piggybank_summary_editor_minimum_wc.setSingleStep(100)
        self.piggybank_summary_editor_minimum_wc.setToolTip("Set the selected editors(s) minimum word count for a single day.\nNote: this will reinforce a rule that makes the maximum word count at least 1000 words more than itself.")
        self.piggybank_summary_editor_maximum_wc_label = QtGui.QLabel("Maximum Word Count:")
        self.piggybank_summary_editor_maximum_wc = QtGui.QSpinBox()
        self.piggybank_summary_editor_maximum_wc.setRange(0,5000)
        self.piggybank_summary_editor_maximum_wc.setSingleStep(100)
        self.piggybank_summary_editor_maximum_wc.setToolTip("Set the selected editors(s) maximum word count for a single day.\nNote: When changed, it will change the minimum word count so as to satisfy a range of at least 1000 words.")
        self.piggybank_summary_editor_total_wc_label = QtGui.QLabel("Total Word Count (Auto):")
        self.piggybank_summary_editor_total_wc = QtGui.QSpinBox()
        self.piggybank_summary_editor_total_wc.setValue(0)
        self.piggybank_summary_editor_total_wc.setRange(0,3000000)
        self.piggybank_summary_editor_total_wc.setEnabled(False)
        self.piggybank_summary_editor_total_wc.setToolTip("This is an auto-generated field which shows the optimum word count calculated by the system.")
        self.piggybank_summary_reset_stats = QtGui.QPushButton("Reset Editor Stats")


        self.piggybank_summary_tables = QtGui.QTabWidget()
        tab_style = """
            QTabWidget::pane { /* The tab widget frame */
            border-top: 2px solid black;
            position: absolute;
            top: -0.5em;
        }

        QTabWidget::tab-bar {
            alignment: center;
        }

        /* Style the tab using the tab sub-control. Note that
            it reads QTabBar _not_ QTabWidget */
        QTabBar::tab {
            background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                        stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
                                        stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
            border: 2px solid #C4C4C3;
            border-bottom-color: black; /* same as the pane color */
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            min-width: 8ex;
            padding: 2px;
        }

        QTabBar::tab:selected, QTabBar::tab:hover {
            background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                        stop: 0 #fafafa, stop: 0.4 #f4f4f4,
                                        stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
        }

        QTabBar::tab:selected {
            border-color: #9B9B9B;
            border-bottom-color: black; /* same as pane color */
        }
        """
        #self.piggybank_summary_tables.setStyleSheet(tab_style)
        self.piggybank_summary_tables.addTab(self.piggybank_summary,"Piggy Bank Summary")
        self.piggybank_summary_tables.addTab(self.piggybank_summary_editor_summary, "Editor Summary")
        self.piggybank_summary_tables.addTab(self.piggybank_summary_random_fsns,"Random FSNs")
        
        self.piggybank_summary_layout = QtGui.QGridLayout()
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_column_chooser_label,0,0)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_column_chooser,0,1)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editors_equality_checkbox,0,2)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_refresh_button,0,3)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_reset_stats,0,4)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editors_label,1,0)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editors_list,1,1)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_audit_percentage_label,1,2)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_audit_percentage,1,3)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_utilization_label,1,4)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_utilization,1,5)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_minimum_wc_label,2,0)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_minimum_wc,2,1)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_maximum_wc_label,2,2)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_maximum_wc,2,3)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_total_wc_label,2,4)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_total_wc,2,5)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_tables,3,0,8,8)
        self.piggybank_summary_widget.setLayout(self.piggybank_summary_layout)
        
        self.piggybank_tabs = QtGui.QTabWidget()
        self.piggybank_tabs.addTab(self.piggybank,"Piggy Bank")
        self.piggybank_tabs.addTab(self.piggybank_summary_widget,"Audit Planner")
        
        self.reset_button = QtGui.QPushButton("Reset Selected Filters")
        self.reset_button.setToolTip("Click here to reset all chosen filters.")
        self.reset_button.setMinimumWidth(120)
        self.reset_button.setMinimumHeight(20)
        reset_style_string = """
            .QPushButton {
                background-color: red;
                color: white;
                font: 8pt;
            }
            .QPushButton:hover {
                background-color: black;
                color: red;
                font: bold 8pt;
            }
            """
        #self.reset_button.setStyleSheet(reset_style_string)
        self.pull_button = QtGui.QPushButton("Pull Data")
        self.pull_button.setToolTip("Click here to extract data from the OINK server for the selected filters.")
        self.pull_button.setMinimumWidth(150)
        self.pull_button.setMinimumHeight(30)
        style_string = """
        .QPushButton {
            background-color: #0088D6;
            color: #FDDE2E;
            font: 12pt;
        }
        .QPushButton:hover {
            background-color: #FDDE2E;
            color: #0088D6;
            font: bold 12pt;
        }
        """
        #self.pull_button.setStyleSheet(style_string)

        self.description_types_selector = DescriptionTypeSelector(self.category_tree)

        self.sources_label = QtGui.QLabel("Source:")
        self.sources_filter_box = CheckableComboBox("Sources")
        sources = list(set(self.category_tree["Source"]))
        self.sources_filter_box.addItems(sources)


        sources_layout = QtGui.QHBoxLayout()
        sources_layout.addWidget(self.sources_label,0)
        sources_layout.addWidget(self.sources_filter_box,1)
        sources_layout.addStretch(2)

        filters_layout = QtGui.QVBoxLayout()
        filters_layout.addWidget(self.instruction_label)
        filters_sub_layouts = [QtGui.QHBoxLayout() for i in range(5)]
        filters_sub_layouts[0].addWidget(self.all_time_dates,0)
        filters_sub_layouts[0].addWidget(self.start_date_edit,0)
        filters_sub_layouts[0].addWidget(self.end_date_edit,0)
        filters_sub_layouts[0].addWidget(self.writers_filter_box,0)
        filters_sub_layouts[1].addLayout(self.description_types_selector,0)
        filters_sub_layouts[2].addLayout(sources_layout,0)
        filters_sub_layouts[3].addLayout(self.category_selector,1)
        filters_sub_layouts[4].addWidget(self.brands_filter_box,0)
        filters_sub_layouts[4].addWidget(self.reset_button,0)
        filters_sub_layouts[4].addWidget(self.pull_button,2)

        for each_layout in filters_sub_layouts:
            filters_layout.addLayout(each_layout)
        filters_layout.addWidget(self.piggybank_summarizer,2)
        filter_and_piggybank_layout = QtGui.QHBoxLayout()
        filter_and_piggybank_layout.addLayout(filters_layout,0)
        filter_and_piggybank_layout.addWidget(self.piggybank_tabs,2)
        layout = QtGui.QVBoxLayout()
        layout.addLayout(filter_and_piggybank_layout,3)
        self.status = QtGui.QLabel("")
        layout.addWidget(self.status,0)
        self.setLayout(layout)
        self.setWindowTitle("Piggy Bank and Audit Planner")
        if "OINKModules" in os.getcwd():
            icon_file_name_path = os.path.join(os.path.join('..',"Images"),'PORK_Icon.png')
        else:
            icon_file_name_path = os.path.join('Images','PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
        self.move(120,100)

    def mapEvents(self):
        self.start_date_edit.dateChanged.connect(self.limitEndDate)
        self.end_date_edit.dateChanged.connect(self.changeEndDate)
        self.all_time_dates.stateChanged.connect(self.toggleDates)
        self.pull_button.clicked.connect(self.pullData)
        self.piggybank_summary_refresh_button.clicked.connect(self.summarize)
        self.piggybank_summary_editors_equality_checkbox.stateChanged.connect(self.toggleEditorEquality)
        self.piggybank_summary_editors_list.currentIndexChanged.connect(self.changePage)
        self.piggybank_summary_editor_utilization.valueChanged.connect(self.changeUtilization)
        self.piggybank_summary_audit_percentage.valueChanged.connect(self.changeAuditPercentage)
        self.piggybank_summary_editor_maximum_wc.valueChanged.connect(self.changeMaxWordCount)
        self.piggybank_summary_editor_minimum_wc.valueChanged.connect(self.changeMinWordCount)
        self.piggybank_summary_reset_stats.clicked.connect(self.summaryFormReset)
        self.reset_button.clicked.connect(self.resetFilters)

    def resetFilters(self):
        self.description_types_filter_box.clearSelection()
        self.sources_filter_box.clearSelection()
        self.writers_filter_box.clearSelection()
        self.category_selector.clearFilters()
        self.brands_filter_box.clearSelection()
        self.start_date_edit.setDate(datetime.date.today())
        self.end_date_edit.setDate(datetime.date.today())

    def changeUtilization(self):
        current_page = str(self.piggybank_summary_editors_list.currentText())
        self.editor_audit_constraints[current_page]["Editor Utilization"] = self.piggybank_summary_editor_utilization.value()

    def changeAuditPercentage(self):
        current_page = str(self.piggybank_summary_editors_list.currentText())
        self.editor_audit_constraints[current_page]["Audit Percentage"] = self.piggybank_summary_audit_percentage.value()
        
    def changeMaxWordCount(self):
        new_word_count = self.piggybank_summary_editor_maximum_wc.value()
        self.piggybank_summary_editor_minimum_wc.setMaximum((new_word_count-1000))
        current_page = str(self.piggybank_summary_editors_list.currentText())
        self.editor_audit_constraints[current_page]["Maximum Word Count"] = new_word_count

    def changeMinWordCount(self):
        new_word_count = self.piggybank_summary_editor_minimum_wc.value()
        self.piggybank_summary_editor_maximum_wc.setMinimum((new_word_count+1000))
        current_page = str(self.piggybank_summary_editors_list.currentText())
        self.editor_audit_constraints[current_page]["Minimum Word Count"] = new_word_count

    def changePage(self):
        current_page = str(self.piggybank_summary_editors_list.currentText())
        self.piggybank_summary_audit_percentage.setValue(self.editor_audit_constraints[current_page]["Audit Percentage"])
        self.piggybank_summary_editor_utilization.setValue(self.editor_audit_constraints[current_page]["Editor Utilization"])
        self.piggybank_summary_editor_minimum_wc.setValue(self.editor_audit_constraints[current_page]["Minimum Word Count"])
        self.piggybank_summary_editor_maximum_wc.setValue(self.editor_audit_constraints[current_page]["Maximum Word Count"])
        self.piggybank_summary_editor_total_wc.setValue(self.editor_audit_constraints[current_page]["Total Word Count"])

    def limitEndDate(self):
        self.end_date_edit.setMinimumDate(self.start_date_edit.date())
        self.end_date_edit.setDate(self.start_date_edit.date())
        self.populateWriters()
        #self.resetEditorConstraints()
        #self.changePage()

    def changeEndDate(self):
        pass
        #self.resetEditorConstraints()
        #self.changePage()

    def toggleDates(self,state):
        if state == 0:
            self.start_date_edit.setEnabled(True)
            self.end_date_edit.setEnabled(True)
        else:
            self.start_date_edit.setEnabled(False)
            self.end_date_edit.setEnabled(False)
    
    def toggleEditorEquality(self, state):
        if state == 0:
            self.piggybank_summary_editors_list.setEnabled(True)
        else:
            self.piggybank_summary_editors_list.setEnabled(False)
            self.piggybank_summary_editors_list.setCurrentIndex(self.piggybank_summary_editors_list.findText("All"))

    def populateWriters(self):
        self.writers_filter_box.clear()
        start_date = self.start_date_edit.date().toPyDate()
        end_date = self.end_date_edit.date().toPyDate()
        self.writers_list = MOSES.getWritersList(self.user_id, self.password, start_date)

        writers = list(set(self.writers_list["Name"]))
        writers.sort()
        self.writers_filter_box.addItems(writers)

    def populateBrand(self):
        self.brands_filter_box.clear()
        self.brands_filter_box.addItems(self.brands)

    def pullData(self):
        #print "Pulling data!"
        self.pull_button.setEnabled(False)
        self.piggybank_summarizer.setEnabled(False)
        self.piggybank.showDataFrame(None)
        message = "processing..."
        self.status.setText(message)
        self.alertMessage("Please Wait","Depending on the filters you have chosen, this step could take a second or a minute, though definitely not more than 60s. Please wait, and remember, <i>Roma die uno non aedificata est</i>.")
        filters = self.getFilters()
        data = MOSES.getPiggyBankWithFilters(self.user_id, self.password, filters)
        if data is None:
            message = "No data for selected filters."
            self.status.setText(message)            
            self.alertMessage("No Data Available","There is no data pertaining to the selected filters. This could have occurred for several reasons:\n1. You may have selected too many filters which have no result, or\n2. You could have selected a date range between which there have been no articles.")        
        else:
            if data.shape[0] <=0:
                self.status.setText(message)            
                message = "No data for selected filters."
                self.alertMessage("No Data Available","There is no data pertaining to the selected filters. This could have occurred for several reasons:\n1. You may have selected too many filters which have no result, or\n2. You could have selected a date range between which there have been no articles, or, simply\n3. There is no data.")
            else:            
                self.piggybank_data = data
                self.piggybank.showDataFrame(self.piggybank_data)
                #populate the summary next.
                self.piggybank_summarizer.setEnabled(True)
                self.piggybank_summarizer.setPiggyBank(data)
                message = "Retrieved %d rows of data pertaining to your filters."%(data.shape[0])
                self.alertMessage("Retrieved Data",message)
                self.status.setText(message)
                #self.summarize()
        self.pull_button.setEnabled(True)

    def showDataFrameInTable(self, dataframe, table_object):
        table_object.showDataFrame(dataframe)

    def getSummarizeParameters(self):
        summarize_parameters = self.piggybank_summary_column_chooser.getCheckedItems()
        if summarize_parameters == []:
            summarize_parameters = ["Writer Name","Category","Description Type"]
        return summarize_parameters

    def getBreakUpTableFromPiggyBank(self):
        data = self.piggybank_data
        summarize_parameters = self.getSummarizeParameters()
        #Build a summary matrix with the different types of the selected summarize parameters.
        matrix = []
        for row in data:
            row_qualifier = dict((key,None) for key in summarize_parameters)
            for key in summarize_parameters:
                row_qualifier[key] = row[key]
            matrix.append(row_qualifier)
        #Build a dictionary which the values for the selected summarize parameters.
        result = [dict(tupleized) for tupleized in set(tuple(item.items()) for item in matrix)]
        return result, summarize_parameters


    def summarize(self):
        """
        This is the audit planner and summarization method. It does several things.
        1. It summarizes the piggy bank that has been pulled. 
            By default, it summarizes by writer x description type x category. This can be changed using the filterbox provided for the summarization columns.
        2. It also computes the optimum audit plan given a set of constraints that can be changed at will using the form. An equalized method may also be used, depending upon need. This is mainly designed for calibration at a later stage.
            (a) Note that there are some problems with how audit numbers will be pulled up. 
                This has nothing to do with the code, but it is rooted in the process itself.
            (b) If a writer reports irregular numbers on a regular basis, this will increase the editors' work for a 
                timeframe as opposed to situations where he posts regular work. 
                The solution for this is to even out the spikes in efficiency.
            (c) In situations where evening out the efficiency spikes is impossible, calibration of audit numbers over a timeframe is recommended. This is out of the scope of this code for the time being, and depending upon
                feedback and feasibility, it may be incorporated at a later stage.
            (d) Long story short, if a writer reports 0% on one day and 200% on the next, the code will decrease an editor's
                overall audit percentage to equalize the fairness of the audit percentage. Although this solves the problem
                for the current time frame, if repeated regularly, it will give that writer a much lesser audit percentage
                than the rest of the team. If this is acceptable, then there's no cause for concern.
                If this isn't acceptable, then the editor will need to generate the audit plan for a set of dates, and check
                the difference in audit numbers. The editor will need to pick up extra audits as required, and naturally, these
                are outside the 100% efficiency for his or her day. This will give the editor extra efficiency for the day.
            (e) General Note:
        3. After pulling the audit plan, it loops through the piggy bank and pulls up random fsns to satisfy the requirements pf the plan and displays this data.
        """
        result, summarize_parameters = self.getBreakUpTableFromPiggyBank()
        #Now process for audit percentages
        #First, check if you're looking at this at a writer level
        #If writer level, check if all editors' efficiency is equalized.
        #If the following are satisfied, use overall stats, not the editors' values.
        equalize_editors = True
        if "Writer Name" in summarize_parameters:
            if not self.piggybank_summary_editors_equality_checkbox.isChecked():
                equalize_editors = False
                summarize_parameters.append("Editor Name")

        #Set a bool to check the audit conditions.
        audit_conditions_satisfied = False

        #Now calculate the upper and lower limits based on the utilization and min/max word counts.
        for editor in self.editor_audit_constraints.keys():
            editor_data = self.editor_audit_constraints[editor]
            editor_data["Audit Conditions Satisfied"] = False
            editor_data["Target Maximum Word Count"] = editor_data["Editor Utilization"]*editor_data["Maximum Word Count"]
            editor_data["Target Minimum Word Count"] = editor_data["Editor Utilization"]*editor_data["Minimum Word Count"]
    
        #Now, for as long as the audit conditions aren't satisfied, keep repeating the following steps.
        first_run = True
        counter = 0
        while not audit_conditions_satisfied:
            counter+=1
            for editor in self.editor_audit_constraints.keys():
                if not self.editor_audit_constraints[editor]["Audit Conditions Satisfied"]:
                    self.editor_audit_constraints[editor]["Total Word Count"] = 0
                    self.editor_audit_constraints[editor]["Audit Count"] = 0
                    #print "Resetting %s's word count." %editor

            #For each row in the result, count the numbers from the piggy bank data set.
            for qualifier_row in result:
                if first_run:
                    qualifier_row["Article Count"] = 0
                    qualifier_row["Word Count"] = 0
                    for row in self.piggybank_data:
                        row_match = True
                        for key in qualifier_row:
                            if (key not in ["Article Count", "Word Count", "Suggested Audits","Approx. Word Count of Audits"]):
                                if qualifier_row[key] != row[key]:
                                    row_match = False
                        if row_match:
                            qualifier_row["Article Count"] += 1
                            qualifier_row["Word Count"] += row["Word Count"]
                #Now, plan the suggested audits.
                #If the editors have equalized targets.
                if equalize_editors:
                    audit_percentage = self.editor_audit_constraints["All"]["Audit Percentage"]/100
                    qualifier_row["Suggested Audits"] = int(math.ceil(audit_percentage*qualifier_row["Article Count"]))
                    self.editor_audit_constraints["All"]["Audit Count"] += qualifier_row["Suggested Audits"]
                    qualifier_row["Approx. Word Count of Audits"] = int(math.ceil(qualifier_row["Suggested Audits"]*qualifier_row["Word Count"]/qualifier_row["Article Count"]))
                    self.editor_audit_constraints["All"]["Total Word Count"] += qualifier_row["Approx. Word Count of Audits"]
                else:
                    try:
                        editor_name = self.getEditorName(qualifier_row["Writer Name"])
                        if not self.editor_audit_constraints[editor_name]["Audit Conditions Satisfied"]:
                            qualifier_row["Editor Name"] = editor_name
                            audit_percentage = self.editor_audit_constraints[editor_name]["Audit Percentage"]/100
                            qualifier_row["Suggested Audits"] = int(math.ceil(audit_percentage*qualifier_row["Article Count"]))
                            self.editor_audit_constraints[editor_name]["Audit Count"] += qualifier_row["Suggested Audits"]
                            qualifier_row["Approx. Word Count of Audits"] = int(math.ceil(qualifier_row["Suggested Audits"]*qualifier_row["Word Count"]/qualifier_row["Article Count"]))
                            self.editor_audit_constraints[editor_name]["Total Word Count"] += qualifier_row["Approx. Word Count of Audits"]
                    except KeyError:
                        print "PiggyBankWithFilter:Summarize: %s doesn't have a mapped editor."%qualifier_row["Writer Name"]
                    except Exception, e:
                        print "PiggyBankWithFilter:Summarize: Encountered error: %s."%repr(e)

            #Check if the audit conditions have been satisfied.
            if equalize_editors:
                scope = "All"
                if self.editor_audit_constraints[scope]["Total Word Count"] <= self.editor_audit_constraints[scope]["Target Minimum Word Count"]:
                    self.editor_audit_constraints[scope]["Audit Percentage"] += self.piggybank_summary_audit_percentage.singleStep()
                    if self.editor_audit_constraints[scope]["Audit Percentage"] > 100:
                        self.alertMessage("Error Planning Audits","Audit percentage is out of bounds. Set to %d%%" %(self.editor_audit_constraints[scope]["Audit Percentage"]))
                        self.editor_audit_constraints[scope]["Audit Conditions Satisfied"] = True
                    else:
                        #print "Increasing audit percentage to", self.editor_audit_constraints[scope]["Audit Percentage"]
                        self.editor_audit_constraints[scope]["Audit Percentage"] += self.piggybank_summary_audit_percentage.singleStep()
                elif self.editor_audit_constraints[scope]["Total Word Count"] >= self.editor_audit_constraints[scope]["Target Maximum Word Count"]:
                    #Editors are over-utilized
                    #print "Over-utilizing %s!" %scope
                    #print """Target Max and Min WCs : %(Target Maximum Word Count)d, %(Target Minimum Word Count)d. Total WC: %(Total Word Count)d""" %(self.editor_audit_constraints[scope])
                    if self.editor_audit_constraints[scope]["Audit Percentage"] <= 1:
                        #print self.editor_audit_constraints[scope]
                        self.alertMessage("Error Planning Audits","Audit percentage is out of bounds. Set to %d%%" %(self.editor_audit_constraints[scope]["Audit Percentage"]))
                        self.editor_audit_constraints[scope]["Audit Conditions Satisfied"] = True
                    else:
                        self.editor_audit_constraints[scope]["Audit Percentage"] -= self.piggybank_summary_audit_percentage.singleStep()
                        #print "Decreasing audit percentage to", self.editor_audit_constraints[scope]["Audit Percentage"]
                elif (self.editor_audit_constraints[scope]["Total Word Count"] >= self.editor_audit_constraints[scope]["Target Minimum Word Count"]) and (self.editor_audit_constraints[scope]["Total Word Count"] <= self.editor_audit_constraints[scope]["Target Maximum Word Count"]):
                    #print "%s is well used.!" %scope
                    if self.editor_audit_constraints[scope]["Audit Percentage"] < 0:
                        raise Exception
                    #print """Target Max and Min WCs : %(Target Maximum Word Count)d, %(Target Minimum Word Count)d. Total WC: %(Total Word Count)d""" %(self.editor_audit_constraints[scope])
                    self.editor_audit_constraints[scope]["Audit Conditions Satisfied"] = True
                else:
                    raise Exception
                audit_conditions_satisfied = self.editor_audit_constraints[scope]["Audit Conditions Satisfied"]
            else:
                editors = self.editor_audit_constraints.keys()
                editors.remove("All")
                editors.sort()
                audit_conditions_satisfied = True
                for editor in editors:
                    scope = editor
                        #Editors are under-utilized
                    if self.editor_audit_constraints[scope]["Total Word Count"] <= self.editor_audit_constraints[scope]["Target Minimum Word Count"]:
                        #print "Under-utilizing %s!" %scope
                        #print """Target Max and Min WCs : %(Target Maximum Word Count)d, %(Target Minimum Word Count)d. Total WC: %(Total Word Count)d""" %(self.editor_audit_constraints[scope])
                        if self.editor_audit_constraints[scope]["Audit Percentage"] >= 100:
                            self.alertMessage("Error Planning Audits","%s's audit percentage is out of bounds. Set to %d%%" %(scope,self.editor_audit_constraints[scope]["Audit Percentage"]))
                            self.editor_audit_constraints[scope]["Audit Conditions Satisfied"] = True
                        else:
                            #print "Increasing audit percentage to", self.editor_audit_constraints[scope]["Audit Percentage"]
                            self.editor_audit_constraints[scope]["Audit Percentage"] += self.piggybank_summary_audit_percentage.singleStep()
                    elif self.editor_audit_constraints[scope]["Total Word Count"] >= self.editor_audit_constraints[scope]["Target Maximum Word Count"]:
                        #Editors are over-utilized
                        #print "Over-utilizing %s!" %scope
                        #print """Target Max and Min WCs : %(Target Maximum Word Count)d, %(Target Minimum Word Count)d. Total WC: %(Total Word Count)d""" %(self.editor_audit_constraints[scope])
                        if self.editor_audit_constraints[scope]["Audit Percentage"] <= 1:
                            self.alertMessage("Error Planning Audits","%s's audit percentage is out of bounds. Set to %d%%" %(scope,self.editor_audit_constraints[scope]["Audit Percentage"]))
                            self.editor_audit_constraints[scope]["Audit Conditions Satisfied"] = True
                        else:
                            #print "Decreasing audit percentage to", self.editor_audit_constraints[scope]["Audit Percentage"]
                            self.editor_audit_constraints[scope]["Audit Percentage"] -= self.piggybank_summary_audit_percentage.singleStep()
                    elif (self.editor_audit_constraints[scope]["Total Word Count"] >= self.editor_audit_constraints[scope]["Target Minimum Word Count"]) and (self.editor_audit_constraints[scope]["Total Word Count"] <= self.editor_audit_constraints[scope]["Target Maximum Word Count"]):
                        #print "%s is well used.!" %scope
                        if self.editor_audit_constraints[scope]["Audit Percentage"] < 0:
                            self.alertMessage("Error Planning Audits","%s's audit percentage is out of bounds. Set to %d%%" %(scope,self.editor_audit_constraints[scope]["Audit Percentage"]))
                            raise Exception
                        #print """Target Max and Min WCs : %(Target Maximum Word Count)d, %(Target Minimum Word Count)d. Total WC: %(Total Word Count)d""" %(self.editor_audit_constraints[scope])
                        self.editor_audit_constraints[scope]["Audit Conditions Satisfied"] = True
                    else:
                        raise Exception
                    audit_conditions_satisfied = self.editor_audit_constraints[editor]["Audit Conditions Satisfied"] and audit_conditions_satisfied
            if counter >= 100:
                self.alertMessage("Infinite Loop","Since the code was stuck in an infinite loop trying to calculate an optimum audit breakup, the program has triggered a failsafe.")
                audit_conditions_satisfied = True
            first_run = False
        headers = summarize_parameters + ["Article Count", "Word Count", "Suggested Audits","Approx. Word Count of Audits"]
        self.piggybank_summary.setRowCount(len(result))
        self.piggybank_summary.setColumnCount(len(headers))
        row_index = 0
        self.piggybank_summary.setSortingEnabled(False)
        for qualifier_row in result:
            column_index = 0
            for key in headers:
                self.piggybank_summary.setItem(row_index, column_index, QtGui.QTableWidgetItem(str(qualifier_row[key])))
                column_index += 1
            row_index += 1
        self.piggybank_summary.setSortingEnabled(True)
        self.piggybank_summary.setHorizontalHeaderLabels(headers)
        self.piggybank_summary.resizeColumnsToContents()
        self.piggybank_summary.resizeRowsToContents()
        
        self.piggybank_summary_editor_summary.setSortingEnabled(False)
        editors = self.editor_audit_constraints.keys()
        editors.remove("All")
        editors.sort()
        row_index = 0
        self.piggybank_summary_editor_summary.setRowCount(3)
        editor_summary_labels = ["Editor Name", "Audit Count", "Total Word Count", "Target Minimum Word Count", "Target Maximum Word Count", "Audit Percentage"]
        self.piggybank_summary_editor_summary.setColumnCount(len(editor_summary_labels))
        for editor in editors:
            self.piggybank_summary_editor_summary.setItem(row_index,0,QtGui.QTableWidgetItem(editor))
            self.piggybank_summary_editor_summary.setItem(row_index,1,QtGui.QTableWidgetItem(str(self.editor_audit_constraints[editor]["Audit Count"])))
            self.piggybank_summary_editor_summary.setItem(row_index,2,QtGui.QTableWidgetItem(str(self.editor_audit_constraints[editor]["Total Word Count"])))
            self.piggybank_summary_editor_summary.setItem(row_index,3,QtGui.QTableWidgetItem(str(self.editor_audit_constraints[editor]["Target Minimum Word Count"])))
            self.piggybank_summary_editor_summary.setItem(row_index,4,QtGui.QTableWidgetItem(str(self.editor_audit_constraints[editor]["Target Maximum Word Count"])))
            self.piggybank_summary_editor_summary.setItem(row_index,5,QtGui.QTableWidgetItem(str(self.editor_audit_constraints[editor]["Audit Percentage"])))
            row_index +=1
        self.piggybank_summary_editor_summary.setSortingEnabled(True)
        self.piggybank_summary_editor_summary.setHorizontalHeaderLabels(editor_summary_labels)
        self.piggybank_summary_editor_summary.resizeColumnsToContents()
        self.piggybank_summary_editor_summary.resizeRowsToContents()
        self.audit_break_up = result
        self.alertMessage("Completed Audit Plan","Completed Audit Plan for %s"%self.start_date_edit.date().toPyDate())
        self.changePage()
        self.randomizeAudits()
Ejemplo n.º 13
0
    def createUI(self):
        self.instruction_label = QtGui.QLabel("<b>Select filters from the following:</b>")

        self.writers_filter_box = CheckableComboBox("Writers")
        self.writers_filter_box.setToolTip("Select the writers whose data you'd like to extract.")

        self.category_selector = CategorySelector(self.category_tree)

        self.brands_filter_box = CheckableComboBox("Brands")
        self.brands_filter_box.setToolTip("Select the Brands you'd like to extract.")

        self.start_date_edit = QtGui.QDateTimeEdit()
        self.start_date_edit.setToolTip("Select the start date for the data set you'd like to extract.")
        self.start_date_edit.setCalendarPopup(True)
        self.start_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.start_date_edit.setMinimumDate(QtCore.QDate(2015,1,1))
        
        lwd = MOSES.getLastWorkingDate(self.user_id, self.password, queryUser="******")
        self.start_date_edit.setDate(lwd)

        self.end_date_edit = QtGui.QDateTimeEdit()
        self.end_date_edit.setToolTip("Select the End Date for the data set you'd like to extract.")
        self.end_date_edit.setDate(QtCore.QDate(datetime.date.today()))
        self.end_date_edit.setCalendarPopup(True)
        self.end_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.end_date_edit.setMinimumDate(self.start_date_edit.date().toPyDate())
        self.end_date_edit.setMaximumDate(datetime.date.today())
        self.end_date_edit.setDate(lwd)

        self.all_time_dates = QtGui.QCheckBox("Pull All Time Data")
        self.all_time_dates.setToolTip("Check this box to pull data for the selected filter from all available data.")

        self.piggybank_summarizer = PiggyBankSummarizer()
        self.piggybank_summarizer.setToolTip("This widget can be used to summarize the piggybank in various ways.")
        self.piggybank_summarizer.setEnabled(False)

        self.piggybank = CopiableQTableWidget(0,0)
        self.piggybank.setToolTip("This table shows all available data for the selected filters.")
        self.piggybank.setStyleSheet("gridline-color: rgb(0, 0, 0)")


        self.piggybank_summary_widget = QtGui.QWidget()
        self.piggybank_summary_column_chooser_label = QtGui.QLabel("Select Column(s):")
        self.piggybank_summary_column_chooser = CheckableComboBox("Columns")
        self.piggybank_summary_column_chooser.setToolTip("Select the piggy bank columns you'd like to summarize.")
        self.piggybank_summary_column_chooser.addItems(["Writer Name","Source", "Description Type", "BU","Super-Category", "Category", "Sub-Category", "Vertical", "Brand"])
        self.piggybank_summary_refresh_button = QtGui.QPushButton("Refresh Summary Table")
        self.piggybank_summary_refresh_button.setToolTip("Click this button to recalculate the audit plan and break up for the selected parameters.")
        
        self.piggybank_summary = CopiableQTableWidget(0,0)
        self.piggybank_summary.setToolTip("This table displays a break up of all the available data between the selected dates, for the chosen filters,\nbased on the summarization columns you've picked.")
        self.piggybank_summary.setStyleSheet("gridline-color: rgb(0, 0, 0)")

        self.piggybank_summary_random_fsns = CopiableQTableWidget(0,0)
        self.piggybank_summary_random_fsns.setToolTip("This table displays a list of random FSNs each editor must audit to satisfy his or her requirements for the selected duration.")
        self.piggybank_summary_random_fsns.setStyleSheet("gridline-color: rgb(0, 0, 0)")
        self.piggybank_summary_editor_summary = CopiableQTableWidget(0,0)
        self.piggybank_summary_editor_summary.setStyleSheet("gridline-color: rgb(0, 0, 0)")
        self.piggybank_summary_audit_percentage_label = QtGui.QLabel("Audit Percentage:")
        self.piggybank_summary_audit_percentage = QtGui.QSpinBox()
        self.piggybank_summary_audit_percentage.setToolTip("This shows the audit percentage for the selected editor(s).")
        self.piggybank_summary_audit_percentage.setRange(0,100)
        self.piggybank_summary_audit_percentage.setSuffix("%")
        self.piggybank_summary_editors_label = QtGui.QLabel("Editor:")
        self.piggybank_summary_editors_list = QtGui.QComboBox()
        self.piggybank_summary_editors_list.setToolTip("Select an editor to display his or her constraints for the chosen time frame.")
        self.piggybank_summary_editors_list.setToolTip("Select an editor to view his or her constraints.")
        self.resetEditorConstraints()
        editors_list = self.editor_audit_constraints.keys()
        editors_list.sort()
        self.piggybank_summary_editors_list.addItems(editors_list)
        self.piggybank_summary_editors_equality_checkbox = QtGui.QCheckBox("Use Equal Targets For All Editors")
        self.piggybank_summary_editors_equality_checkbox.setToolTip("When checked, this nullifies all the personal constraints for editors and treats them equally.\nThis is enabled by default when you purposely remove writer names' from the columns filter.\nUse this when calibrating.")
        self.piggybank_summary_editors_equality_checkbox.setCheckState(False)
        self.piggybank_summary_editor_utilization_label = QtGui.QLabel("Editor Utilization:")
        self.piggybank_summary_editor_utilization = QtGui.QDoubleSpinBox()
        self.piggybank_summary_editor_utilization.setToolTip("Set a utilization factor here.\n1.0 indicates 100%% for a duration of 1 day. If there are multiple working dates selected, then the utilization changes accordingly.\nNote: This doesn't accomodate for leaves taken by editors as of this version.")
        self.piggybank_summary_editor_utilization.setRange(0,3000.0)
        self.piggybank_summary_editor_utilization.setSingleStep(0.05)
        self.piggybank_summary_editor_minimum_wc_label = QtGui.QLabel("Minimum Word Count:")
        self.piggybank_summary_editor_minimum_wc = QtGui.QSpinBox()
        self.piggybank_summary_editor_minimum_wc.setRange(0,5000)
        self.piggybank_summary_editor_minimum_wc.setSingleStep(100)
        self.piggybank_summary_editor_minimum_wc.setToolTip("Set the selected editors(s) minimum word count for a single day.\nNote: this will reinforce a rule that makes the maximum word count at least 1000 words more than itself.")
        self.piggybank_summary_editor_maximum_wc_label = QtGui.QLabel("Maximum Word Count:")
        self.piggybank_summary_editor_maximum_wc = QtGui.QSpinBox()
        self.piggybank_summary_editor_maximum_wc.setRange(0,5000)
        self.piggybank_summary_editor_maximum_wc.setSingleStep(100)
        self.piggybank_summary_editor_maximum_wc.setToolTip("Set the selected editors(s) maximum word count for a single day.\nNote: When changed, it will change the minimum word count so as to satisfy a range of at least 1000 words.")
        self.piggybank_summary_editor_total_wc_label = QtGui.QLabel("Total Word Count (Auto):")
        self.piggybank_summary_editor_total_wc = QtGui.QSpinBox()
        self.piggybank_summary_editor_total_wc.setValue(0)
        self.piggybank_summary_editor_total_wc.setRange(0,3000000)
        self.piggybank_summary_editor_total_wc.setEnabled(False)
        self.piggybank_summary_editor_total_wc.setToolTip("This is an auto-generated field which shows the optimum word count calculated by the system.")
        self.piggybank_summary_reset_stats = QtGui.QPushButton("Reset Editor Stats")


        self.piggybank_summary_tables = QtGui.QTabWidget()
        tab_style = """
            QTabWidget::pane { /* The tab widget frame */
            border-top: 2px solid black;
            position: absolute;
            top: -0.5em;
        }

        QTabWidget::tab-bar {
            alignment: center;
        }

        /* Style the tab using the tab sub-control. Note that
            it reads QTabBar _not_ QTabWidget */
        QTabBar::tab {
            background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                        stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
                                        stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
            border: 2px solid #C4C4C3;
            border-bottom-color: black; /* same as the pane color */
            border-top-left-radius: 4px;
            border-top-right-radius: 4px;
            min-width: 8ex;
            padding: 2px;
        }

        QTabBar::tab:selected, QTabBar::tab:hover {
            background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                        stop: 0 #fafafa, stop: 0.4 #f4f4f4,
                                        stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
        }

        QTabBar::tab:selected {
            border-color: #9B9B9B;
            border-bottom-color: black; /* same as pane color */
        }
        """
        #self.piggybank_summary_tables.setStyleSheet(tab_style)
        self.piggybank_summary_tables.addTab(self.piggybank_summary,"Piggy Bank Summary")
        self.piggybank_summary_tables.addTab(self.piggybank_summary_editor_summary, "Editor Summary")
        self.piggybank_summary_tables.addTab(self.piggybank_summary_random_fsns,"Random FSNs")
        
        self.piggybank_summary_layout = QtGui.QGridLayout()
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_column_chooser_label,0,0)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_column_chooser,0,1)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editors_equality_checkbox,0,2)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_refresh_button,0,3)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_reset_stats,0,4)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editors_label,1,0)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editors_list,1,1)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_audit_percentage_label,1,2)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_audit_percentage,1,3)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_utilization_label,1,4)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_utilization,1,5)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_minimum_wc_label,2,0)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_minimum_wc,2,1)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_maximum_wc_label,2,2)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_maximum_wc,2,3)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_total_wc_label,2,4)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_editor_total_wc,2,5)
        self.piggybank_summary_layout.addWidget(self.piggybank_summary_tables,3,0,8,8)
        self.piggybank_summary_widget.setLayout(self.piggybank_summary_layout)
        
        self.piggybank_tabs = QtGui.QTabWidget()
        self.piggybank_tabs.addTab(self.piggybank,"Piggy Bank")
        self.piggybank_tabs.addTab(self.piggybank_summary_widget,"Audit Planner")
        
        self.reset_button = QtGui.QPushButton("Reset Selected Filters")
        self.reset_button.setToolTip("Click here to reset all chosen filters.")
        self.reset_button.setMinimumWidth(120)
        self.reset_button.setMinimumHeight(20)
        reset_style_string = """
            .QPushButton {
                background-color: red;
                color: white;
                font: 8pt;
            }
            .QPushButton:hover {
                background-color: black;
                color: red;
                font: bold 8pt;
            }
            """
        #self.reset_button.setStyleSheet(reset_style_string)
        self.pull_button = QtGui.QPushButton("Pull Data")
        self.pull_button.setToolTip("Click here to extract data from the OINK server for the selected filters.")
        self.pull_button.setMinimumWidth(150)
        self.pull_button.setMinimumHeight(30)
        style_string = """
        .QPushButton {
            background-color: #0088D6;
            color: #FDDE2E;
            font: 12pt;
        }
        .QPushButton:hover {
            background-color: #FDDE2E;
            color: #0088D6;
            font: bold 12pt;
        }
        """
        #self.pull_button.setStyleSheet(style_string)

        self.description_types_selector = DescriptionTypeSelector(self.category_tree)

        self.sources_label = QtGui.QLabel("Source:")
        self.sources_filter_box = CheckableComboBox("Sources")
        sources = list(set(self.category_tree["Source"]))
        self.sources_filter_box.addItems(sources)


        sources_layout = QtGui.QHBoxLayout()
        sources_layout.addWidget(self.sources_label,0)
        sources_layout.addWidget(self.sources_filter_box,1)
        sources_layout.addStretch(2)

        filters_layout = QtGui.QVBoxLayout()
        filters_layout.addWidget(self.instruction_label)
        filters_sub_layouts = [QtGui.QHBoxLayout() for i in range(5)]
        filters_sub_layouts[0].addWidget(self.all_time_dates,0)
        filters_sub_layouts[0].addWidget(self.start_date_edit,0)
        filters_sub_layouts[0].addWidget(self.end_date_edit,0)
        filters_sub_layouts[0].addWidget(self.writers_filter_box,0)
        filters_sub_layouts[1].addLayout(self.description_types_selector,0)
        filters_sub_layouts[2].addLayout(sources_layout,0)
        filters_sub_layouts[3].addLayout(self.category_selector,1)
        filters_sub_layouts[4].addWidget(self.brands_filter_box,0)
        filters_sub_layouts[4].addWidget(self.reset_button,0)
        filters_sub_layouts[4].addWidget(self.pull_button,2)

        for each_layout in filters_sub_layouts:
            filters_layout.addLayout(each_layout)
        filters_layout.addWidget(self.piggybank_summarizer,2)
        filter_and_piggybank_layout = QtGui.QHBoxLayout()
        filter_and_piggybank_layout.addLayout(filters_layout,0)
        filter_and_piggybank_layout.addWidget(self.piggybank_tabs,2)
        layout = QtGui.QVBoxLayout()
        layout.addLayout(filter_and_piggybank_layout,3)
        self.status = QtGui.QLabel("")
        layout.addWidget(self.status,0)
        self.setLayout(layout)
        self.setWindowTitle("Piggy Bank and Audit Planner")
        if "OINKModules" in os.getcwd():
            icon_file_name_path = os.path.join(os.path.join('..',"Images"),'PORK_Icon.png')
        else:
            icon_file_name_path = os.path.join('Images','PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
        self.move(120,100)
Ejemplo n.º 14
0
    def createUI(self):
        self.base_data_set_group = FilterForm(
                                            self.user_id,   
                                            self.password,    
                                            (0,0,0),   
                                            self.category_tree,   
                                            "Base Data Set")
        self.comparison_data_set_group = FilterForm(
                                            self.user_id, 
                                            self.password, 
                                            (0,0,0), 
                                            self.category_tree, 
                                            "Comparison Data Set")

        self.analysis_parameters_group = QtGui.QGroupBox("Analysis Parameters")
        self.parameters_label = QtGui.QLabel("Compare:")
        self.parameters_combobox = CheckableComboBox("Parameters")
        self.parameters_all_button = QtGui.QPushButton("All")
        self.parameters_cfm_button = QtGui.QPushButton("CFM")
        self.parameters_gseo_button = QtGui.QPushButton("GSEO")
        self.parameters_fatal_button = QtGui.QPushButton("Fatals")
        self.parameters_clear_button = QtGui.QPushButton("None")



        parameters_layout = QtGui.QVBoxLayout()
        
        parameter_selection_row = QtGui.QHBoxLayout()
        parameter_selection_row.addWidget(self.parameters_label)
        parameter_selection_row.addWidget(self.parameters_combobox)

        parameters_buttons_layout = QtGui.QHBoxLayout()
        parameters_buttons_layout.addWidget(self.parameters_all_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_cfm_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_gseo_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_fatal_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_clear_button, QtCore.Qt.AlignTop)

        parameters_layout.addLayout(parameter_selection_row)
        parameters_layout.addLayout(parameters_buttons_layout)
        
        self.analysis_parameters_group.setLayout(parameters_layout)

        self.plot_options_group = QtGui.QGroupBox("Plotting Options")
        self.plot_type_label = QtGui.QLabel("Plot:")
        self.plot_type_combobox = CheckableComboBox("Chart Types")
        self.plot_types = [
                            "Pareto"
                        ]
        self.plot_type_combobox.addItems(self.plot_types)
        self.plot_type_combobox.selectAll()
        self.plot_separate_charts_for_each_parameter = QtGui.QCheckBox("Parameter Charts")
        
        self.use_minimum_acceptable_scores = QtGui.QCheckBox("Consider an acceptable article to be the base")
        self.use_minimum_acceptable_scores.setToolTip("If checked, the tool will plot charts by considering an article with\n96% CFM and 95% GSEO article to be the base.\nOtherwise, it compares scores against a 100 article.")
        
        self.use_rejected_audits = QtGui.QCheckBox("Use Rejected Audits")
        self.use_rejected_audits.setToolTip("If checked, the tool will also consider rejected audits for analysis.")

        self.load_data_button = QtGui.QPushButton("Load Data")
        self.plot_button = QtGui.QPushButton("Plot Charts")
        self.plot_save_button = QtGui.QPushButton("Save Charts")
        self.plot_zoom_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.plot_zoom_label = QtGui.QLabel("100%")
        self.plot_zoom_slider.setRange(10,500)
        self.plot_zoom_slider.setValue(100)
        self.plot_zoom_slider.setSingleStep(1)
        #self.plot_zoom_slider.valueChanged.connect(self.zoomInOut)
        self.plot_zoom_slider.setTickInterval(10)
        self.plot_zoom_slider.setTickPosition(2)

        self.plot_button.setEnabled(False)
        self.plot_save_button.setEnabled(False)

        plot_options_layout = QtGui.QVBoxLayout()

        plot_options_row_1 = QtGui.QHBoxLayout()
        plot_options_row_1.addWidget(self.plot_type_label,0)
        plot_options_row_1.addWidget(self.plot_type_combobox,0)
        plot_options_row_1.addWidget(self.plot_separate_charts_for_each_parameter,0)
        plot_options_layout.addLayout(plot_options_row_1)

        plot_options_row_2 = QtGui.QVBoxLayout()
        plot_options_row_2.addWidget(self.use_minimum_acceptable_scores,1)
        plot_options_row_2.addWidget(self.use_rejected_audits,1)
        plot_options_layout.addLayout(plot_options_row_2)
        
        plot_options_row_3 = QtGui.QHBoxLayout()
        plot_options_row_3.addWidget(self.load_data_button,0)
        plot_options_row_3.addWidget(self.plot_button,0)
        plot_options_row_3.addWidget(self.plot_save_button,0)
        plot_options_row_3.addStretch(1)
        plot_options_layout.addLayout(plot_options_row_3)

        plot_options_row_4 = QtGui.QHBoxLayout()
        plot_options_row_4.addWidget(self.plot_zoom_slider,3)
        plot_options_row_4.addWidget(self.plot_zoom_label,1)
        plot_options_layout.addLayout(plot_options_row_4)

        
        self.plot_options_group.setLayout(plot_options_layout)

        self.plot_viewer_group = QtGui.QGroupBox("Charts and Data")
        self.plot_viewer = ImageLabel()
        self.plot_data_table = CopiableQTableWidget(0,0)

        self.plot_tabs = QtGui.QTabWidget()
        self.plot_tabs.addTab(self.plot_data_table, "Data")
        self.plot_tabs.addTab(self.plot_viewer, "Charts")

        plot_viewer_layout = QtGui.QHBoxLayout()
        plot_viewer_layout.addWidget(self.plot_tabs)
        self.plot_viewer_group.setLayout(plot_viewer_layout)

        self.progress_bar = ProgressBar()
        self.status_label = QtGui.QLabel("He who seeks glory, finds death.")

        row_1_layout = QtGui.QHBoxLayout()
        row_1_layout.addWidget(self.base_data_set_group)
        row_1_layout.addWidget(self.comparison_data_set_group)
        
        column_1_layout = QtGui.QVBoxLayout()
        column_1_layout.addWidget(self.analysis_parameters_group,1)
        column_1_layout.addWidget(self.plot_options_group,1)
        column_1_layout.addStretch(3)
        
        row_2_layout = QtGui.QHBoxLayout()
        row_2_layout.addLayout(column_1_layout,0)
        row_2_layout.addWidget(self.plot_viewer_group,3)

        
        row_3_layout = QtGui.QVBoxLayout()
        row_3_layout.addWidget(self.progress_bar,0)
        row_3_layout.addWidget(self.status_label,0)
        
        tna_viewer_layout = QtGui.QVBoxLayout()
        tna_viewer_layout.addLayout(row_1_layout,1)
        tna_viewer_layout.addLayout(row_2_layout,3)
        tna_viewer_layout.addLayout(row_3_layout,0)

        self.setLayout(tna_viewer_layout)
        self.show()
        self.move(0,0)
        self.setWindowTitle("Training Needs Analyser")
        self.setWindowIcon(QtGui.QIcon(os.path.join('Images','PORK_Icon.png')))
Ejemplo n.º 15
0
class TNAViewer(QtGui.QWidget):
    def __init__(self, user_id, password, category_tree, lock_users=None, *args, **kwargs):
        super(TNAViewer, self).__init__(*args, **kwargs)
        self.user_id = user_id
        self.password = password
        self.category_tree = category_tree
        parameters_date = datetime.date.today()
        self.audit_parameters_dataframe = MOSES.getAuditParametersData(self.user_id, self.password, parameters_date)
        #the viewer level controls the scope of the program.
        #A Level 0 limits the visibility to the current user, and shows the team's quality in comparison.
        #A level 1 allows choosing the users.
        if lock_users is not None:
            self.lock_users = lock_users
        else:
            self.lock_users = False
        self.createUI()
        self.mapEvents()
        self.initiate()

    def initiate(self):
        self.populateBaseEditorAndWritersList()
        self.populateComparisonEditorAndWritersList()
        self.populateAuditParameters()
        if self.lock_users:
            self.base_data_set_group.lock(1)
            self.comparison_data_set_group.lock(2)
            self.alertMessage("PORK Mode!","Welcome to the PORK Mode of the TNA Viewer. This is a simpler mode, which allows you, a writer, to compare yourself with your teammates, or compare your present performance with your past performance.")

    def populateBaseEditorAndWritersList(self):
        self.base_data_set_group.populateEditorAndWritersList()

    def populateComparisonEditorAndWritersList(self):
        self.comparison_data_set_group.populateEditorAndWritersList()

    def populateAuditParameters(self):
        parameters_date = self.base_data_set_group.getDates()[0]
        self.audit_parameters_dataframe = MOSES.getAuditParametersData(self.user_id, self.password, parameters_date)
        self.audit_parameters = self.audit_parameters_dataframe["Column Descriptions"]
        self.parameters_combobox.clear()
        self.parameters_combobox.addItems(self.audit_parameters)

    
    def createUI(self):
        self.base_data_set_group = FilterForm(
                                            self.user_id,   
                                            self.password,    
                                            (0,0,0),   
                                            self.category_tree,   
                                            "Base Data Set")
        self.comparison_data_set_group = FilterForm(
                                            self.user_id, 
                                            self.password, 
                                            (0,0,0), 
                                            self.category_tree, 
                                            "Comparison Data Set")

        self.analysis_parameters_group = QtGui.QGroupBox("Analysis Parameters")
        self.parameters_label = QtGui.QLabel("Compare:")
        self.parameters_combobox = CheckableComboBox("Parameters")
        self.parameters_all_button = QtGui.QPushButton("All")
        self.parameters_cfm_button = QtGui.QPushButton("CFM")
        self.parameters_gseo_button = QtGui.QPushButton("GSEO")
        self.parameters_fatal_button = QtGui.QPushButton("Fatals")
        self.parameters_clear_button = QtGui.QPushButton("None")



        parameters_layout = QtGui.QVBoxLayout()
        
        parameter_selection_row = QtGui.QHBoxLayout()
        parameter_selection_row.addWidget(self.parameters_label)
        parameter_selection_row.addWidget(self.parameters_combobox)

        parameters_buttons_layout = QtGui.QHBoxLayout()
        parameters_buttons_layout.addWidget(self.parameters_all_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_cfm_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_gseo_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_fatal_button, QtCore.Qt.AlignTop)
        parameters_buttons_layout.addWidget(self.parameters_clear_button, QtCore.Qt.AlignTop)

        parameters_layout.addLayout(parameter_selection_row)
        parameters_layout.addLayout(parameters_buttons_layout)
        
        self.analysis_parameters_group.setLayout(parameters_layout)

        self.plot_options_group = QtGui.QGroupBox("Plotting Options")
        self.plot_type_label = QtGui.QLabel("Plot:")
        self.plot_type_combobox = CheckableComboBox("Chart Types")
        self.plot_types = [
                            "Pareto"
                        ]
        self.plot_type_combobox.addItems(self.plot_types)
        self.plot_type_combobox.selectAll()
        self.plot_separate_charts_for_each_parameter = QtGui.QCheckBox("Parameter Charts")
        
        self.use_minimum_acceptable_scores = QtGui.QCheckBox("Consider an acceptable article to be the base")
        self.use_minimum_acceptable_scores.setToolTip("If checked, the tool will plot charts by considering an article with\n96% CFM and 95% GSEO article to be the base.\nOtherwise, it compares scores against a 100 article.")
        
        self.use_rejected_audits = QtGui.QCheckBox("Use Rejected Audits")
        self.use_rejected_audits.setToolTip("If checked, the tool will also consider rejected audits for analysis.")

        self.load_data_button = QtGui.QPushButton("Load Data")
        self.plot_button = QtGui.QPushButton("Plot Charts")
        self.plot_save_button = QtGui.QPushButton("Save Charts")
        self.plot_zoom_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.plot_zoom_label = QtGui.QLabel("100%")
        self.plot_zoom_slider.setRange(10,500)
        self.plot_zoom_slider.setValue(100)
        self.plot_zoom_slider.setSingleStep(1)
        #self.plot_zoom_slider.valueChanged.connect(self.zoomInOut)
        self.plot_zoom_slider.setTickInterval(10)
        self.plot_zoom_slider.setTickPosition(2)

        self.plot_button.setEnabled(False)
        self.plot_save_button.setEnabled(False)

        plot_options_layout = QtGui.QVBoxLayout()

        plot_options_row_1 = QtGui.QHBoxLayout()
        plot_options_row_1.addWidget(self.plot_type_label,0)
        plot_options_row_1.addWidget(self.plot_type_combobox,0)
        plot_options_row_1.addWidget(self.plot_separate_charts_for_each_parameter,0)
        plot_options_layout.addLayout(plot_options_row_1)

        plot_options_row_2 = QtGui.QVBoxLayout()
        plot_options_row_2.addWidget(self.use_minimum_acceptable_scores,1)
        plot_options_row_2.addWidget(self.use_rejected_audits,1)
        plot_options_layout.addLayout(plot_options_row_2)
        
        plot_options_row_3 = QtGui.QHBoxLayout()
        plot_options_row_3.addWidget(self.load_data_button,0)
        plot_options_row_3.addWidget(self.plot_button,0)
        plot_options_row_3.addWidget(self.plot_save_button,0)
        plot_options_row_3.addStretch(1)
        plot_options_layout.addLayout(plot_options_row_3)

        plot_options_row_4 = QtGui.QHBoxLayout()
        plot_options_row_4.addWidget(self.plot_zoom_slider,3)
        plot_options_row_4.addWidget(self.plot_zoom_label,1)
        plot_options_layout.addLayout(plot_options_row_4)

        
        self.plot_options_group.setLayout(plot_options_layout)

        self.plot_viewer_group = QtGui.QGroupBox("Charts and Data")
        self.plot_viewer = ImageLabel()
        self.plot_data_table = CopiableQTableWidget(0,0)

        self.plot_tabs = QtGui.QTabWidget()
        self.plot_tabs.addTab(self.plot_data_table, "Data")
        self.plot_tabs.addTab(self.plot_viewer, "Charts")

        plot_viewer_layout = QtGui.QHBoxLayout()
        plot_viewer_layout.addWidget(self.plot_tabs)
        self.plot_viewer_group.setLayout(plot_viewer_layout)

        self.progress_bar = ProgressBar()
        self.status_label = QtGui.QLabel("He who seeks glory, finds death.")

        row_1_layout = QtGui.QHBoxLayout()
        row_1_layout.addWidget(self.base_data_set_group)
        row_1_layout.addWidget(self.comparison_data_set_group)
        
        column_1_layout = QtGui.QVBoxLayout()
        column_1_layout.addWidget(self.analysis_parameters_group,1)
        column_1_layout.addWidget(self.plot_options_group,1)
        column_1_layout.addStretch(3)
        
        row_2_layout = QtGui.QHBoxLayout()
        row_2_layout.addLayout(column_1_layout,0)
        row_2_layout.addWidget(self.plot_viewer_group,3)

        
        row_3_layout = QtGui.QVBoxLayout()
        row_3_layout.addWidget(self.progress_bar,0)
        row_3_layout.addWidget(self.status_label,0)
        
        tna_viewer_layout = QtGui.QVBoxLayout()
        tna_viewer_layout.addLayout(row_1_layout,1)
        tna_viewer_layout.addLayout(row_2_layout,3)
        tna_viewer_layout.addLayout(row_3_layout,0)

        self.setLayout(tna_viewer_layout)
        self.show()
        self.move(0,0)
        self.setWindowTitle("Training Needs Analyser")
        self.setWindowIcon(QtGui.QIcon(os.path.join('Images','PORK_Icon.png')))

    def mapEvents(self):
        self.load_data_button.clicked.connect(self.loadData)
        self.parameters_all_button.clicked.connect(self.selectAllParameters)
        self.parameters_cfm_button.clicked.connect(self.selectCFMParameters)
        self.parameters_gseo_button.clicked.connect(self.selectGSEOParameters)
        self.parameters_fatal_button.clicked.connect(self.selectFatalParameters)
        self.parameters_clear_button.clicked.connect(self.clearParameterSelections)
        self.plot_button.clicked.connect(self.plotCharts)
        self.base_data_set_group.changedStartDate.connect(self.populateAuditParameters)

        self.base_data_set_group.changedFilter.connect(self.changedFilters)
        self.comparison_data_set_group.changedFilter.connect(self.changedFilters)

    def changedFilters(self):
        self.plot_button.setEnabled(False)

    def plotCharts(self):
        audit_parameter_selection = self.parameters_combobox.getCheckedItems()
        audit_parameters = audit_parameter_selection
        plot_types = self.plot_type_combobox.getCheckedItems()

        if len(plot_types)==0:
            self.alertMessage("No chart types selected!","You'll need to select a type of chart that you want to plot.")
        else:
            if len(audit_parameters)==0:
                self.selectGSEOParameters()
                self.selectCFMParameters()
                audit_parameters = self.parameters_combobox.getCheckedItems()
                self.alertMessage("No parameters selected!","Since you've not selected any audit parameters, GSEO and CFM have been auto selected for you.")
            if "Pareto" in plot_types:
                pareto_image = self.plotPareto(audit_parameters)

    def plotPareto(self, audit_parameter_selection):
        #print self.audit_parameters_dataframe
        parameter_column_names = self.getParameterColumnNames(audit_parameter_selection)
        parameter_class_list = [x[:(len(x)-2)] for x in parameter_column_names]
        #self.printMessage(parameter_column_names)
        parameter_summary_data = []
        counter = 0
        for parameter in audit_parameter_selection:
            parameter_column_name = parameter_column_names[counter]
            if not self.use_minimum_acceptable_scores.isChecked():
                acceptable_score = self.getMaximumScoreForParameter(parameter)
            else:
                acceptable_score = self.getMinimumScoreForParameter(parameter)
            #if "FAT" in parameter_column_name:
            #    self.printMessage("%s-%s: Max. Score: %s"%(parameter_column_name, parameter, acceptable_score))
            if type(acceptable_score) == str:
                #The acceptable score can be a string or a number.
                base_deviant_positions = self.base_data_set[parameter_column_name] != acceptable_score
            else:
                base_deviant_positions = self.base_data_set[parameter_column_name] < acceptable_score

            base_deviation_frequency = self.base_data_set[base_deviant_positions][parameter_column_name].count()
            base_deviation_frequency_percentage = base_deviation_frequency/self.base_data_set.shape[0]
            if self.comparison_data_set is None:
                comparison_deviation_frequency_percentage = "-"
                verdict = "NA"
            else:
                if type(acceptable_score) == str:
                    comparison_deviant_positions = self.comparison_data_set[parameter_column_name] != acceptable_score
                else:
                    comparison_deviant_positions = self.comparison_data_set[parameter_column_name] < acceptable_score

                comparison_deviation_frequency = self.comparison_data_set[comparison_deviant_positions][parameter_column_name].count()
                comparison_deviation_frequency_percentage = comparison_deviation_frequency/self.comparison_data_set.shape[0]
                if base_deviation_frequency_percentage<comparison_deviation_frequency_percentage:
                    verdict = "Better"
                elif base_deviation_frequency_percentage==comparison_deviation_frequency_percentage:
                    verdict = "No Change"
                else:
                    verdict = "Worse"

            parameter_data = [parameter, base_deviation_frequency_percentage, comparison_deviation_frequency_percentage, verdict]
            counter +=1
            parameter_summary_data.append(parameter_data)

        #self.printMessage(parameter_summary_data)
        try:
            summary_data_frame = pd.DataFrame(parameter_summary_data, index=parameter_class_list, columns =["Parameter Description", "Base Deviation Frequency", "Comparison Deviation Frequency","Verdict"]).sort_values(["Base Deviation Frequency"], ascending=False)
        except:
            summary_data_frame = pd.DataFrame(parameter_summary_data, index=parameter_class_list, columns =["Parameter Description", "Base Deviation Frequency", "Comparison Deviation Frequency","Verdict"]).sort(columns=["Base Deviation Frequency"], ascending=False)

        #self.printMessage(summary_data_frame)
        #Clear the canvas
        fig, ax = plt.subplots()

        x_positions = np.arange(len(summary_data_frame.index))
        width = 0.35

        base_data_list = [x*100 for x in summary_data_frame["Base Deviation Frequency"]]
        base_bar_graphs = ax.bar(x_positions, base_data_list, width, color='y')
        ax.set_xticks(x_positions+width)
        parameter_names = [self.wordWrap(x) for x in list(summary_data_frame["Parameter Description"])]
        ax.set_xticklabels(parameter_names, rotation=90)
        #Set x and y labels.
        ax.set_xlabel("Quality Parameters")
        ax.set_ylabel("Deviation Frequency Percentage\n(Lower the bar, better the performance)")
        
        user_name = MOSES.getEmpName(self.user_id)
        time_stamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")

        ax.set_title("Pareto Chart\n[Generated by OINK for %s at %s]"%(user_name, time_stamp))
        
        base_label = self.base_data_set_group.getLabel()
        reference_label = self.comparison_data_set_group.getLabel()

        if self.comparison_data_set is not None:
            comparison_data_list = [x*100 for x in summary_data_frame["Comparison Deviation Frequency"]]
            comparison_bar_graphs = ax.bar(x_positions+width, comparison_data_list, width, color='g')
            ax.legend((base_bar_graphs[0], comparison_bar_graphs[0]), (base_label, reference_label))
        
        self.plot_data_table.showDataFrame(summary_data_frame)
        plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.5)
        filename = os.path.join(os.getcwd(),"cache","Pareto_%s_vs_%s_%s.png"%(base_label.replace(" ","_"), reference_label.replace(" ","_"), time_stamp))

        plt.savefig("%s"%filename)
        self.plot_viewer.showImage(filename, int(self.plot_data_table.size().width()),int(self.plot_data_table.size().height()))
        plt.show()

        pareto_image_object = True
        return pareto_image_object

    def wordWrap(self, base_text):
        if " " in base_text:
            output_text = base_text[:base_text.find(" ")] + "\n" + base_text[base_text.find(" ")+1:]
        else:
            output_text = base_text
        return output_text
    
    def getMaximumScoreForParameter(self, parameter_name):
        matching_indices = self.audit_parameters_dataframe["Column Descriptions"]==parameter_name
        rating_type = list(self.audit_parameters_dataframe[matching_indices]["Rating Type"])[0]
        if rating_type!="Mandatory":
            maximum_score = list(self.audit_parameters_dataframe[matching_indices]["Maximum Score"])[0]
        else:
            maximum_score = "No" #No denotes that there's no fatal.
        return maximum_score

    def getMinimumScoreForParameter(self, parameter_name):
        matching_indices = self.audit_parameters_dataframe["Column Descriptions"]==parameter_name
        rating_type = list(self.audit_parameters_dataframe[matching_indices]["Rating Type"])[0]
        if rating_type!="Mandatory":
            minimum_score = list(self.audit_parameters_dataframe[matching_indices]["Minimum Acceptable Score"])[0]
        else:
            minimum_score = "No" #No denotes that there's no fatal.
        return minimum_score

    def getParameterColumnNames(self, audit_parameter_selection):
        audit_parameter_classes = list(self.audit_parameters_dataframe[self.audit_parameters_dataframe["Column Descriptions"].isin(audit_parameter_selection)]["Parameter Class"])
        
        audit_parameter_class_indices = list(self.audit_parameters_dataframe[self.audit_parameters_dataframe["Column Descriptions"].isin(audit_parameter_selection)]["Parameter Class Index"])        
        column_names = ["%s%02d"%(x,y) for (x,y) in zip(audit_parameter_classes, audit_parameter_class_indices)]
        #self.printMessage(column_names)
        return column_names

    def printMessage(self, msg):
        allow_print = True
        if allow_print:
            print "TNAViewer: %s"%msg
        
    def loadData(self):
        self.load_data_button.setEnabled(False)
        self.alertMessage("Please wait...","Depending on the filters you have chosen, this step could take a second or a minute, though definitely not more than 60s. Please wait, and remember, <i>Roma die uno non aedificata est</i>.")
        self.plot_button.setEnabled(False)
        base_filter = self.base_data_set_group.getFilters()
        comparison_filter = self.comparison_data_set_group.getFilters()
        if self.use_rejected_audits.isChecked():
            self.base_data_set = pd.concat([
                                        MOSES.getRawDataWithFilters(self.user_id, self.password, base_filter),
                                        MOSES.getRawDataWithFilters(self.user_id, self.password, base_filter, rejected=True)
                                        ])
            self.comparison_data_set = pd.concat([
                                        MOSES.getRawDataWithFilters(self.user_id, self.password, comparison_filter),
                                        MOSES.getRawDataWithFilters(self.user_id, self.password, comparison_filter, rejected=True)
                                        ])
        else:
            self.base_data_set = MOSES.getRawDataWithFilters(self.user_id, self.password, base_filter)
            self.comparison_data_set = MOSES.getRawDataWithFilters(self.user_id, self.password, comparison_filter)

        if self.base_data_set is not None:
            base_count = self.base_data_set.shape[0]
        else:
            base_count = 0

        if self.comparison_data_set is not None:
            comparison_count = self.comparison_data_set.shape[0]
        else:
            comparison_count = 0

        if base_count >0:
            self.plot_button.setEnabled(True)
            if comparison_count == 0:
                self.alertMessage("Retrieved Data","Retrieved %d audits for the base filters. There don't seem to be any for the comparison data set. You can go ahead and still plot a chart to analyse the base data, albeit without a reference plotted against it."%(base_count))
            else:
                self.alertMessage("Retrieved Data","Retrieved %d audits matching the base filters and %d audits matching the comparison filters."%(base_count, comparison_count))

        else:
            self.plot_button.setEnabled(False)
            self.alertMessage("Insufficient Base Data","There are no audits matching the selected filters for the base data. It is impossible to plot a chart without base data. This could have occurred for several reasons:\n1. You may have selected too many filters which have no result in the base form, or\n2. You could have selected a date range between which there have been zero audits.")
        self.load_data_button.setEnabled(True)


    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)

    def selectAllParameters(self):
        self.selectGSEOParameters()
        self.selectCFMParameters()
        self.selectFatalParameters()


    def selectGSEOParameters(self):
        gseo_parameters = self.audit_parameters_dataframe["Column Descriptions"][self.audit_parameters_dataframe["Parameter Class"] == "GSEO"]
        for gseo_parameter in gseo_parameters:
            self.parameters_combobox.select(gseo_parameter)

    def selectCFMParameters(self):
        cfm_parameters = self.audit_parameters_dataframe["Column Descriptions"][self.audit_parameters_dataframe["Parameter Class"] == "CFM"]
        for cfm_parameter in cfm_parameters:
            self.parameters_combobox.select(cfm_parameter)

    def selectFatalParameters(self):
        fatal_parameters = self.audit_parameters_dataframe["Column Descriptions"][self.audit_parameters_dataframe["Parameter Class"] == "FAT"]
        for fatal_parameter in fatal_parameters:
            self.parameters_combobox.select(fatal_parameter)

    def clearParameterSelections(self):
        self.parameters_combobox.clearSelection()
Ejemplo n.º 16
0
class DescriptionTypeSelector(QtGui.QHBoxLayout):
    def __init__(self, category_tree, *args, **kwargs):
        super(DescriptionTypeSelector, self).__init__(*args, **kwargs)
        self.category_tree = category_tree
        self.createUI()

    def createUI(self):
        self.label = QtGui.QLabel("Description Type:")
        self.filter_box = CheckableComboBox("Description Types")
        self.filter_box.addItems(
            list(set(self.category_tree["Description Type"])))
        self.PD_button = QtGui.QPushButton("PD")
        self.RPD_button = QtGui.QPushButton("RPD")
        self.SEO_button = QtGui.QPushButton("SEO")
        self.USP_button = QtGui.QPushButton("USP")
        self.clear_button = QtGui.QPushButton("Clear")
        self.addWidget(self.label, 1)
        self.addWidget(self.filter_box, 2)
        self.addWidget(self.PD_button, 1)
        self.addWidget(self.RPD_button, 1)
        self.addWidget(self.SEO_button, 1)
        self.addWidget(self.USP_button, 1)
        self.addWidget(self.clear_button, 1)
        self.mapEvents()

    def mapEvents(self):
        self.PD_button.clicked.connect(self.selectPD)
        self.RPD_button.clicked.connect(self.selectRPD)
        self.SEO_button.clicked.connect(self.selectSEO)
        self.USP_button.clicked.connect(self.selectUSP)
        self.clear_button.clicked.connect(self.clear)

    def selectPD(self):
        self.filter_box.selectIfTextFound("Regular")
        #self.filter_box.select("Regular Description")

    def selectRPD(self):
        self.filter_box.selectIfTextFound("RPD")
        self.filter_box.selectIfTextFound("Rich Product Description")

    def selectSEO(self):
        self.filter_box.selectIfTextFound("SEO")

    def selectUSP(self):
        self.filter_box.selectIfTextFound("USP")

    def clear(self):
        self.filter_box.clearSelection()

    def getCheckedItems(self):
        if len(self.filter_box.getCheckedItems()) == 0:
            self.selectSEO()
            self.selectRPD()
            self.selectPD()
        return self.filter_box.getCheckedItems()
Ejemplo n.º 17
0
class DailyPorker(QtGui.QWidget):
    def __init__(self, user_id, password, category_tree=None):
        super(DailyPorker, self).__init__()
        self.user_id, self.password = user_id, password
        self.report_list = []
        if category_tree is None:
            self.category_tree = MOSES.getCategoryTree(self.user_id, self.password)
        else:
            self.category_tree = category_tree
        #self.pork_kent = PorkKent(self.user_id, self.password)
        style_string = """
        .QTableWidget {
            gridline-color: rgb(0, 0, 0);
        }
        """
        self.setStyleSheet(style_string)
        self.clip = QtGui.QApplication.clipboard()
        self.createUI()
        self.mapEvents()
        self.initiate()
        self.show()

    def initiate(self):
        self.center()
        self.populateWritersComboBox()
        self.writers_combobox.selectAll()
        self.refreshSortFilter()

    def center(self):
        #frameGm = self.frameGeometry()
        #screen = QtGui.QApplication.desktop().screenNumber(QtGui.QApplication.desktop().cursor().pos())
        #centerPoint = QtGui.QApplication.desktop().screenGeometry(screen).center()
        #frameGm.moveCenter(centerPoint)
        #self.move(frameGm.topLeft())
        self.move(70,50)

    def createUI(self):
        self.start_date_label = QtGui.QLabel("<b>Date:</b>")
        self.start_date_edit = QtGui.QDateTimeEdit()
        self.start_date_edit.setToolTip("Set the date for which you want to generate the report.")
        lwd = MOSES.getLastWorkingDate(self.user_id, self.password, queryUser="******")
        self.start_date_edit.setDate(lwd)
        self.start_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.start_date_edit.setMinimumDate(QtCore.QDate(2015,1,1))
        self.start_date_edit.setCalendarPopup(True)

        self.end_date_edit = QtGui.QDateTimeEdit()
        self.end_date_edit.setToolTip("Select an end date. Only working days will be considered for the calculation.\nThis field will be disabled if the checkbox isn't marked to calculate the average statistics between dates.")
        self.end_date_edit.setDate(self.start_date_edit.date())
        self.end_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.end_date_edit.setMinimumDate(self.start_date_edit.date())
        self.end_date_edit.setCalendarPopup(True)

        self.writers_combobox = CheckableComboBox("Writers")
        self.writers_combobox.setToolTip("Select a group of writers if you want to check their performance for some time frame.")

        report_names = ["Article Count","Efficiency","Audit Count","CFM","GSEO","Stack Rank Index","Efficiency KRA","CFM KRA","GSEO KRA"]#,"Audit Percentage"]
        self.parameters_combobox = CheckableComboBox("Report Values")
        self.parameters_combobox.addItems(report_names)
        self.parameters_combobox.select(["Efficiency","CFM","GSEO", "Article Count", "Audit Count"])

        self.report_time_frames_combobox = CheckableComboBox("Timeframe")
        self.report_time_frames_combobox.addItems(["Daily","Weekly","Monthly","Quarterly","Half-Yearly"])
        self.report_time_frames_combobox.select(["Daily","Weekly"])

        self.sorting_filter_label = QtGui.QLabel("<b>Sort By:</b>")
        self.sorting_filter_combobox = QtGui.QComboBox()
        self.sorting_filter_combobox.setToolTip("Select the parameter you want to sort the generated reports by.")

        self.build_button = QtGui.QPushButton("Build Daily Team Performance Report")
        self.build_button.setToolTip("Click this button to start building the report")

        self.plot_button = QtGui.QPushButton("Plot")
        self.plot_button.setToolTip("Check this if you want to automatically plot the graphs.")
        
        self.build_dbr_button = QtGui.QPushButton("Build DBR Report")
        self.build_dbr_button.setToolTip("Check this if you want to automatically plot the graphs.")
        
        self.build_wbr_button = QtGui.QPushButton("Build WBR Report")
        self.build_wbr_button.setToolTip("Check this if you want to automatically plot the graphs.")
        
        self.progress_bar = ProgressBar()

        self.export_graphs_button = QtGui.QPushButton("Save")
        self.export_graphs_button.setToolTip("Click this button to save the generated reports and graphs in a desired folder location.")

        self.report = CopiableQTableWidget(0, 0)
        self.t_report = CopiableQTableWidget(0, 0)
        self.dbr_report = CopiableQTableWidget(0, 0)
        self.wbr_report = CopiableQTableWidget(0, 0)

        self.graphs = DailyGraphView()
        self.t_graphs = DailyGraphView()

        self.reports_tab = QtGui.QTabWidget()
        self.reports_tab.addTab(self.report,"Writers' Report")
        #self.reports_tab.addTab(self.graphs, "Writers' Graphs")
        #self.reports_tab.addTab(self.t_report,"Team Report")
        #self.reports_tab.addTab(self.t_graphs, "Team Graphs")
        self.reports_tab.addTab(self.dbr_report, "DBR Report")
        self.reports_tab.addTab(self.wbr_report, "WBR Report")

        self.status = QtGui.QLabel("I'm a Porkitzer Prize Winning Reporter.")

        options_layout_row_1 = QtGui.QHBoxLayout()
        options_layout_row_1.addWidget(self.start_date_label,0)
        options_layout_row_1.addWidget(self.start_date_edit,1)
        options_layout_row_1.addWidget(self.end_date_edit,1)
        options_layout_row_1.addWidget(self.writers_combobox,1)
        options_layout_row_1.addWidget(self.parameters_combobox,1)
        options_layout_row_1.addWidget(self.report_time_frames_combobox,1)
        options_layout_row_1.addStretch(2)
        
        options_layout_row_2 = QtGui.QHBoxLayout()
        options_layout_row_2.addWidget(self.sorting_filter_label,0)
        options_layout_row_2.addWidget(self.sorting_filter_combobox,1)
        options_layout_row_2.addWidget(self.build_button,0)
        #options_layout_row_2.addWidget(self.plot_button,0)
        options_layout_row_2.addWidget(self.build_dbr_button,0)
        options_layout_row_2.addWidget(self.build_wbr_button,0)
        options_layout_row_2.addStretch(2)

        options_layout = QtGui.QVBoxLayout()
        options_layout.addLayout(options_layout_row_1,0)
        options_layout.addLayout(options_layout_row_2,0)
        self.daily_porker_logo = ImageButton(
                                        os.path.join(MOSES.getPathToImages(),"newspaper.png"),
                                        100,
                                        100,
                                        os.path.join(MOSES.getPathToImages(),"newspaper_mouseover.png")
                                    )
        self.daily_porker_logo.setFlat(True)
        options = QtGui.QGroupBox("Report Options")
        options.setLayout(options_layout)
        options_with_logo = QtGui.QHBoxLayout()
        options_with_logo.addWidget(self.daily_porker_logo, 0, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        options_with_logo.addWidget(options, 3)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(options_with_logo,1)
        layout.addWidget(self.reports_tab,3)
        layout.addWidget(self.progress_bar,0)
        layout.addWidget(self.status,0)

        self.setLayout(layout)
        self.setWindowTitle("The Daily Porker: Straight from the Pigs")

        icon_file_name_path = os.path.join(MOSES.getPathToImages(),'PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))

    def mapEvents(self):
        self.build_button.clicked.connect(self.buildReport)
        self.start_date_edit.dateChanged.connect(self.changedStartDate)
        self.pork_lane = PorkLane(self.user_id, self.password, self.category_tree)
        self.pork_lane.sendReport.connect(self.populateReport)
        self.pork_lane.sendProgress.connect(self.displayProgress)
        self.pork_lane.sendGraphs.connect(self.displayGraphs)
        self.report_time_frames_combobox.changedSelection.connect(self.refreshSortFilter)
        self.parameters_combobox.changedSelection.connect(self.refreshSortFilter)
        self.build_dbr_button.clicked.connect(self.buildDBR)
        self.build_wbr_button.clicked.connect(self.buildWBR)

    def buildDBR(self):
        self.build_dbr_button.setEnabled(False)
        self.alertMessage("Please Wait","This could take a while.")
        dbr = MOSES.getDBR(self.user_id, self.password, self.start_date_edit.date().toPyDate(), self.category_tree)
        self.dbr_report.showDataFrame(dbr)
        self.dbr_report.adjustToColumns()
        self.build_dbr_button.setEnabled(True)
        self.alertMessage("Success","Successfully Pulled the DBR")

    def buildWBR(self):
        self.build_wbr_button.setEnabled(False)
        self.alertMessage("Please Wait","This could take a while.")
        wbr = MOSES.getWBR(self.user_id, self.password, self.start_date_edit.date().toPyDate(), self.category_tree)
        self.wbr_report.showDataFrame(wbr)
        self.wbr_report.adjustToColumns()
        self.build_wbr_button.setEnabled(True)
        self.alertMessage("Success","Successfully Pulled the WBR")


    def getWritersList(self):
        self.writers_data_frame = MOSES.getWritersList(self.user_id, self.password, self.start_date_edit.date().toPyDate())
        writer_names_list = list(set(self.writers_data_frame["Name"]))
        writer_names_list.sort()
        return writer_names_list

    def displayGraphs(self,handle):
        if handle:
            self.graphs.graph_date = self.pork_lane.start_date
            self.graphs.enable_plotting = True
            self.graphs.plotGraph()
            self.progress_bar.setRange(0,100)
            self.progress_bar.setFormat("Completed at %s." %(datetime.datetime.strftime(datetime.datetime.now(),"%H:%M:%S")))
            self.status.setText("Beware the alien, the mutant, the heretic.")  
            self.progress_bar.setValue(100)
            #self.export_graphs_button.setEnabled(True)
        else:
            self.export_graphs_button.setEnabled(False)
            self.status.setText("Creating Graphs...")        
            self.progress_bar.setValue(0)
            self.progress_bar.setRange(0,0)


    def refreshSortFilter(self):
        report_types = self.getRequiredReportTypes()
        self.sorting_filter_combobox.clear()
        if len(report_types) > 0:
            self.sorting_filter_combobox.setEnabled(True)
            self.sorting_filter_combobox.addItems(report_types)
        else:
            self.sorting_filter_combobox.setEnabled(False)
        self.sorting_filter_combobox.setCurrentIndex(-1)

    def buildReport(self):
        self.build_button.setEnabled(False)
        report_types = self.getRequiredReportTypes()
        if len(report_types) > 0:
            self.build = True
            self.pork_lane.writers_data_frame = self.writers_data_frame
            self.pork_lane.parameter_list = self.parameters_combobox.getCheckedItems() #set pork lane report types.]
            self.pork_lane.time_frame_list = self.report_time_frames_combobox.getCheckedItems()
            selected_writers_list = self.writers_combobox.getCheckedItems()
            if len(selected_writers_list)>0:
                self.pork_lane.writers_list = selected_writers_list
            else:
                self.writers_combobox.selectAll()
                selected_writers_list = self.writers_combobox.getCheckedItems()
                self.pork_lane.writers_list = selected_writers_list
            self.pork_lane.start_date = self.start_date_edit.date().toPyDate()
            self.pork_lane.end_date = self.end_date_edit.date().toPyDate()
            self.pork_lane.allowRun = True #allow building.
        else:
            self.build = False
            self.alertMessage("Error","Please select at least one parameter in the checklist before attempting to build the report.")
        self.build_button.setEnabled(True)
            
    def changedStartDate(self):
        self.end_date_edit.setMinimumDate(self.start_date_edit.date())
        self.end_date_edit.setDate(self.start_date_edit.date())
        self.populateWritersComboBox()

    def populateWritersComboBox(self):
        self.writers_combobox.clear()
        self.writers_combobox.addItems(self.getWritersList())
        self.writers_combobox.selectAll()

    def getRequiredReportTypes(self):
        parameter_list = self.parameters_combobox.getCheckedItems()
        time_frame_list = self.report_time_frames_combobox.getCheckedItems()
        reports_list = ["%s %s"%(time_frame, parameter_type) for time_frame in time_frame_list for parameter_type in parameter_list]
        return reports_list

    def populateReport(self, report):
        mode = self.pork_lane.mode
        columns = ["Report Date", "Writer ID", "Writer Email ID", "Writer Name", "Reporting Manager"]
        columns += mode
        self.report.setRowCount(0)
        row_counter = 0

        self.report.setColumnCount(len(columns))
        self.report.setHorizontalHeaderLabels(columns)
        self.report.setSortingEnabled(False)
        red = QtGui.QColor(231, 90, 83)
        green = QtGui.QColor(60, 179, 113)
        blue = QtGui.QColor(23, 136, 216)

        for writer_row in report:
            self.report.insertRow(row_counter)
            column_counter = 0
            for column_name in columns:
                if ("Efficiency" in column_name) and ("KRA" not in column_name):
                    steps = [1.00, 1.05, 1.10]
                elif (("CFM" in column_name) or ("GSEO" in column_name)) and ("KRA" not in column_name):
                    steps = [0.95, 0.97]
                elif ("KRA" in column_name) or ("Index" in column_name):
                    steps = [3.0,4.0,5.0]
                else:
                    steps = []
                parameter = writer_row[column_name]

                if (type(parameter) == str):
                    parameter_is_valid = False
                elif (parameter is None):
                    parameter_is_valid = False
                elif type(parameter) == float:
                    if math.isnan(parameter):
                        parameter_is_valid = False
                    else:
                        parameter_is_valid = True
                elif type(parameter) == datetime.date:
                    parameter_is_valid = False    
                else:
                    parameter_is_valid = True
                
                if parameter_is_valid:
                    if "Count" in column_name:
                        parameter_as_string = "%03d" % parameter
                    elif ("Stack Rank Index" in column_name) or ("KRA" in column_name):
                        parameter_as_string = "%01.2f" % parameter
                    else:
                        if math.isnan(parameter):
                            parameter_as_string = "-"
                        else:
                            parameter_as_string = "%06.2f%%" %(round(parameter*100,4))
                elif column_name in ["Report Date", "Writer ID", "Writer Name", "Writer Email ID", "Reporting Manager"]:
                    parameter_as_string = str(parameter)
                else:
                    parameter_as_string = "-"

                writer_cell_item = QtGui.QTableWidgetItem(parameter_as_string)
                writer_cell_item.setTextAlignment(QtCore.Qt.AlignCenter)
                if parameter_is_valid:
                    if steps != []:
                        if round(parameter,4) < steps[0]:
                            writer_cell_item.setBackgroundColor(red)
                        elif steps[0] <= (round(parameter,4)) <= steps[1]:
                            writer_cell_item.setBackgroundColor(green)
                        elif (round(parameter,4)) > steps[1]:
                            writer_cell_item.setBackgroundColor(blue)
                self.report.setItem(row_counter, column_counter, writer_cell_item)
                column_counter += 1
            row_counter += 1 
        self.report.setSortingEnabled(True)
        self.report.resizeColumnsToContents()
        self.report.resizeRowsToContents()
        sorting_factor = self.getSortColumn()
        if sorting_factor is not "NA":
            sort_index = mode.index(sorting_factor) + 5
            self.report.sortItems(sort_index,QtCore.Qt.DescendingOrder)

    def getSortColumn(self):
        if self.sorting_filter_combobox.currentIndex() != -1:
            return str(self.sorting_filter_combobox.currentText())
        else:
            return "NA"
            
    def displayProgress(self, progress_text, eta, progress, state):
        if state:
            self.pork_lane.allowRun = False
            self.build_button.setEnabled(True)
            self.progress_bar.setFormat("Completed at %s." %(datetime.datetime.strftime(eta,"%H:%M:%S")))        
            self.progress_bar.setValue(progress)
        else:
            self.build_button.setEnabled(False)
            self.progress_bar.setFormat("%s ETA: %s" %(progress_text, datetime.datetime.strftime(eta,"%H:%M:%S")))
            self.progress_bar.setValue(progress)

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)
Ejemplo n.º 18
0
class DescriptionTypeSelector(QtGui.QHBoxLayout):
    def __init__(self, category_tree, *args, **kwargs):
        super(DescriptionTypeSelector, self).__init__(*args, **kwargs)
        self.category_tree = category_tree
        self.createUI()

    def createUI(self):
        self.label = QtGui.QLabel("Description Type:")
        self.filter_box = CheckableComboBox("Description Types")
        self.filter_box.addItems(list(set(self.category_tree["Description Type"])))
        self.PD_button = QtGui.QPushButton("PD")
        self.RPD_button = QtGui.QPushButton("RPD")
        self.SEO_button = QtGui.QPushButton("SEO")
        self.USP_button = QtGui.QPushButton("USP")
        self.clear_button = QtGui.QPushButton("Clear")
        self.addWidget(self.label,1)
        self.addWidget(self.filter_box,2)
        self.addWidget(self.PD_button,1)
        self.addWidget(self.RPD_button,1)
        self.addWidget(self.SEO_button,1)
        self.addWidget(self.USP_button,1)
        self.addWidget(self.clear_button,1)
        self.mapEvents()

    def mapEvents(self):
        self.PD_button.clicked.connect(self.selectPD)
        self.RPD_button.clicked.connect(self.selectRPD)
        self.SEO_button.clicked.connect(self.selectSEO)
        self.USP_button.clicked.connect(self.selectUSP)
        self.clear_button.clicked.connect(self.clear)
    
    def selectPD(self):
        self.filter_box.selectIfTextFound("Regular")
        #self.filter_box.select("Regular Description")

    def selectRPD(self):
        self.filter_box.selectIfTextFound("RPD")
        self.filter_box.selectIfTextFound("Rich Product Description")
        
    def selectSEO(self):
        self.filter_box.selectIfTextFound("SEO")

    def selectUSP(self):
        self.filter_box.selectIfTextFound("USP")

    def clear(self):
        self.filter_box.clearSelection()

    def getCheckedItems(self):
        if len(self.filter_box.getCheckedItems()) == 0:
            self.selectSEO()   
            self.selectRPD()   
            self.selectPD()
        return self.filter_box.getCheckedItems()
Ejemplo n.º 19
0
    def createUI(self):
        self.start_date_label = QtGui.QLabel("<b>Date:</b>")
        self.start_date_edit = QtGui.QDateTimeEdit()
        self.start_date_edit.setToolTip("Set the date for which you want to generate the report.")
        lwd = MOSES.getLastWorkingDate(self.user_id, self.password, queryUser="******")
        self.start_date_edit.setDate(lwd)
        self.start_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.start_date_edit.setMinimumDate(QtCore.QDate(2015,1,1))
        self.start_date_edit.setCalendarPopup(True)

        self.end_date_edit = QtGui.QDateTimeEdit()
        self.end_date_edit.setToolTip("Select an end date. Only working days will be considered for the calculation.\nThis field will be disabled if the checkbox isn't marked to calculate the average statistics between dates.")
        self.end_date_edit.setDate(self.start_date_edit.date())
        self.end_date_edit.setDisplayFormat("MMMM dd, yyyy")
        self.end_date_edit.setMinimumDate(self.start_date_edit.date())
        self.end_date_edit.setCalendarPopup(True)

        self.writers_combobox = CheckableComboBox("Writers")
        self.writers_combobox.setToolTip("Select a group of writers if you want to check their performance for some time frame.")

        report_names = ["Article Count","Efficiency","Audit Count","CFM","GSEO","Stack Rank Index","Efficiency KRA","CFM KRA","GSEO KRA"]#,"Audit Percentage"]
        self.parameters_combobox = CheckableComboBox("Report Values")
        self.parameters_combobox.addItems(report_names)
        self.parameters_combobox.select(["Efficiency","CFM","GSEO", "Article Count", "Audit Count"])

        self.report_time_frames_combobox = CheckableComboBox("Timeframe")
        self.report_time_frames_combobox.addItems(["Daily","Weekly","Monthly","Quarterly","Half-Yearly"])
        self.report_time_frames_combobox.select(["Daily","Weekly"])

        self.sorting_filter_label = QtGui.QLabel("<b>Sort By:</b>")
        self.sorting_filter_combobox = QtGui.QComboBox()
        self.sorting_filter_combobox.setToolTip("Select the parameter you want to sort the generated reports by.")

        self.build_button = QtGui.QPushButton("Build Daily Team Performance Report")
        self.build_button.setToolTip("Click this button to start building the report")

        self.plot_button = QtGui.QPushButton("Plot")
        self.plot_button.setToolTip("Check this if you want to automatically plot the graphs.")
        
        self.build_dbr_button = QtGui.QPushButton("Build DBR Report")
        self.build_dbr_button.setToolTip("Check this if you want to automatically plot the graphs.")
        
        self.build_wbr_button = QtGui.QPushButton("Build WBR Report")
        self.build_wbr_button.setToolTip("Check this if you want to automatically plot the graphs.")
        
        self.progress_bar = ProgressBar()

        self.export_graphs_button = QtGui.QPushButton("Save")
        self.export_graphs_button.setToolTip("Click this button to save the generated reports and graphs in a desired folder location.")

        self.report = CopiableQTableWidget(0, 0)
        self.t_report = CopiableQTableWidget(0, 0)
        self.dbr_report = CopiableQTableWidget(0, 0)
        self.wbr_report = CopiableQTableWidget(0, 0)

        self.graphs = DailyGraphView()
        self.t_graphs = DailyGraphView()

        self.reports_tab = QtGui.QTabWidget()
        self.reports_tab.addTab(self.report,"Writers' Report")
        #self.reports_tab.addTab(self.graphs, "Writers' Graphs")
        #self.reports_tab.addTab(self.t_report,"Team Report")
        #self.reports_tab.addTab(self.t_graphs, "Team Graphs")
        self.reports_tab.addTab(self.dbr_report, "DBR Report")
        self.reports_tab.addTab(self.wbr_report, "WBR Report")

        self.status = QtGui.QLabel("I'm a Porkitzer Prize Winning Reporter.")

        options_layout_row_1 = QtGui.QHBoxLayout()
        options_layout_row_1.addWidget(self.start_date_label,0)
        options_layout_row_1.addWidget(self.start_date_edit,1)
        options_layout_row_1.addWidget(self.end_date_edit,1)
        options_layout_row_1.addWidget(self.writers_combobox,1)
        options_layout_row_1.addWidget(self.parameters_combobox,1)
        options_layout_row_1.addWidget(self.report_time_frames_combobox,1)
        options_layout_row_1.addStretch(2)
        
        options_layout_row_2 = QtGui.QHBoxLayout()
        options_layout_row_2.addWidget(self.sorting_filter_label,0)
        options_layout_row_2.addWidget(self.sorting_filter_combobox,1)
        options_layout_row_2.addWidget(self.build_button,0)
        #options_layout_row_2.addWidget(self.plot_button,0)
        options_layout_row_2.addWidget(self.build_dbr_button,0)
        options_layout_row_2.addWidget(self.build_wbr_button,0)
        options_layout_row_2.addStretch(2)

        options_layout = QtGui.QVBoxLayout()
        options_layout.addLayout(options_layout_row_1,0)
        options_layout.addLayout(options_layout_row_2,0)
        self.daily_porker_logo = ImageButton(
                                        os.path.join(MOSES.getPathToImages(),"newspaper.png"),
                                        100,
                                        100,
                                        os.path.join(MOSES.getPathToImages(),"newspaper_mouseover.png")
                                    )
        self.daily_porker_logo.setFlat(True)
        options = QtGui.QGroupBox("Report Options")
        options.setLayout(options_layout)
        options_with_logo = QtGui.QHBoxLayout()
        options_with_logo.addWidget(self.daily_porker_logo, 0, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
        options_with_logo.addWidget(options, 3)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(options_with_logo,1)
        layout.addWidget(self.reports_tab,3)
        layout.addWidget(self.progress_bar,0)
        layout.addWidget(self.status,0)

        self.setLayout(layout)
        self.setWindowTitle("The Daily Porker: Straight from the Pigs")

        icon_file_name_path = os.path.join(MOSES.getPathToImages(),'PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))
Ejemplo n.º 20
0
class UserManager(QtGui.QMainWindow):
    def __init__(self, user_id, password,*args, **kwargs):
        super(UserManager, self).__init__(*args, **kwargs)
        self.user_id, self.password = user_id, password
        #get the list of users from MOSES.
        self.refreshData()
        self.createUI()
        self.mapEvents()
        self.initialize()

    def refreshData(self):
        self.employees_data = MOSES.getEmployeesList(self.user_id, self.password)
        self.manager_mapping_data = MOSES.getManagerMappingTable(self.user_id, self.password)

    def createUI(self):
        self.users_list_label = QtGui.QLabel("Users: ")
        self.users_list_view = QtGui.QListWidget()

        self.add_employee_button = ImageButton(
                                        os.path.join("Images","add.png"),
                                            48,
                                            48,
                                            os.path.join("Images","add_mouseover.png")
                                        )
        self.edit_employee_button = ImageButton(
                                            os.path.join("Images","modify.png"),
                                            48,
                                            48,
                                            os.path.join("Images","modify_mouseover.png")
                                        )

        self.edit_employee_button.setCheckable(True)
        self.add_employee_button.setCheckable(True)
        self.button_group = QtGui.QButtonGroup()
        self.button_group.addButton(self.edit_employee_button)
        self.button_group.addButton(self.add_employee_button)
        self.button_group.setExclusive(True)


        user_list_buttons_layout = QtGui.QHBoxLayout()
        user_list_buttons_layout.addWidget(self.add_employee_button,0)
        user_list_buttons_layout.addWidget(self.edit_employee_button,0)

        users_list_layout = QtGui.QVBoxLayout()
        users_list_layout.addWidget(self.users_list_label,0)
        users_list_layout.addWidget(self.users_list_view,3)
        users_list_layout.addLayout(user_list_buttons_layout,1)
        users_list_layout.addStretch(1)

        self.employee_id_label = QtGui.QLabel("Employee ID")
        self.employee_id_lineedit = QtGui.QLineEdit()
        self.employee_name_label = QtGui.QLabel("Name")
        self.employee_name_lineedit = QtGui.QLineEdit()
        name_id_row = QtGui.QHBoxLayout()
        name_id_row.addWidget(self.employee_id_label,0)
        name_id_row.addWidget(self.employee_id_lineedit,2)
        name_id_row.addWidget(self.employee_name_label,0)
        name_id_row.addWidget(self.employee_name_lineedit,2)

        self.email_label = QtGui.QLabel("Email ID:")
        self.email_lineedit = QtGui.QLineEdit()
        email_row = QtGui.QHBoxLayout()
        email_row.addWidget(self.email_label,0)
        email_row.addWidget(self.email_lineedit,2)

        self.current_role_label = QtGui.QLabel("Role:")
        self.current_role_combobox = QtGui.QComboBox()
        current_role_row = QtGui.QHBoxLayout()
        current_role_row.addWidget(self.current_role_label,0)
        current_role_row.addWidget(self.current_role_combobox,1)

        self.doj_label = QtGui.QLabel("Date of Joining:")
        self.doj_dateedit = FormattedDateEdit()
        self.dol_checkbox = QtGui.QCheckBox("Last Working Date:")
        self.dol_checkbox.setToolTip("Check to mark the LWD of this employee.\nLeave unchecked if the employee is still in the team.")
        self.dol_dateedit = FormattedDateEdit()
        self.doj_dateedit.setCalendarPopup(True)
        self.dol_dateedit.setCalendarPopup(True)

        doj_dol_row = QtGui.QHBoxLayout()
        doj_dol_row.addWidget(self.doj_label, 0)
        doj_dol_row.addWidget(self.doj_dateedit, 0)
        doj_dol_row.addWidget(self.dol_checkbox, 0)
        doj_dol_row.addWidget(self.dol_dateedit, 0)

        self.former_role_label = QtGui.QLabel("Former Role:")
        self.former_role_combobox = QtGui.QComboBox()
        self.dop_checkbox = QtGui.QCheckBox("Promoted")
        self.dop_checkbox.setToolTip("Check this to record a promotion and keep details of the former role.")
        self.dop_label = QtGui.QLabel("Date of Promotion:")
        self.dop_dateedit = FormattedDateEdit()
        self.dop_dateedit.setCalendarPopup(True)

        promotion_row = QtGui.QHBoxLayout()
        promotion_row.addWidget(self.dop_checkbox, 0)
        promotion_row.addWidget(self.dop_label, 0)
        promotion_row.addWidget(self.dop_dateedit, 1)
        promotion_row.addWidget(self.former_role_label, 0)
        promotion_row.addWidget(self.former_role_combobox, 1)

        self.access_label = QtGui.QLabel("OINK Application Access")
        self.access_combobox = CheckableComboBox("Applications")
        self.access_combobox.addItems(["PORK","BACON","VINDALOO"])
        access_row = QtGui.QHBoxLayout()
        access_row.addWidget(self.access_label,0)
        access_row.addWidget(self.access_combobox,2)
        access_row.addStretch(1)

        self.reset_password_button = QtGui.QPushButton("Reset Password")
        self.save_button = QtGui.QPushButton("Save")
        self.reset_button = QtGui.QPushButton("Revert")

        form_buttons_layout = QtGui.QHBoxLayout()
        form_buttons_layout.addStretch(2)
        form_buttons_layout.addWidget(self.reset_password_button,0)
        form_buttons_layout.addWidget(self.save_button,0)
        form_buttons_layout.addWidget(self.reset_button,0)

        self.progress_bar = ProgressBar()
        self.status_label = QtGui.QLabel()

        self.manager_mapping = CopiableQTableWidget(0,0)

        self.manager_name_label = QtGui.QLabel("Reporting Manager:")
        self.manager_name_combobox = QtGui.QComboBox()
        self.manager_effective_date_label = QtGui.QLabel("Revision Date:")
        self.manager_effective_dateedit = FormattedDateEdit()
        self.manager_effective_dateedit.setDate(datetime.date.today())
        self.manager_effective_dateedit.setCalendarPopup(True)
        self.add_new_manager_mapping_row = QtGui.QPushButton("Add or Update")
        self.remove_manager_mapping_row = QtGui.QPushButton("Remove")

        manager_mapping_form = QtGui.QHBoxLayout()
        manager_mapping_form.addWidget(self.manager_name_label,0)
        manager_mapping_form.addWidget(self.manager_name_combobox,2)
        manager_mapping_form.addWidget(self.manager_effective_date_label,0)
        manager_mapping_form.addWidget(self.manager_effective_dateedit,1)
        manager_mapping_form.addWidget(self.add_new_manager_mapping_row,0)
        manager_mapping_form.addWidget(self.remove_manager_mapping_row,0)

        user_data_form_layout = QtGui.QVBoxLayout()
        user_data_form_layout.addLayout(name_id_row,0)
        user_data_form_layout.addLayout(email_row,0)
        user_data_form_layout.addLayout(current_role_row,0)
        user_data_form_layout.addLayout(doj_dol_row,0)
        user_data_form_layout.addLayout(promotion_row,0)
        user_data_form_layout.addLayout(access_row,0)
        user_data_form_layout.addLayout(form_buttons_layout,0)
        user_data_form_layout.addWidget(self.manager_mapping,1)
        user_data_form_layout.addLayout(manager_mapping_form,0)
        user_data_form_layout.addStretch(1)
        user_data_form_layout.addWidget(self.progress_bar,0)
        user_data_form_layout.addWidget(self.status_label,0)

        user_data_form = QtGui.QGroupBox("User Information:")
        user_data_form.setLayout(user_data_form_layout)

        layout = QtGui.QHBoxLayout()
        layout.addLayout(users_list_layout,1)
        layout.addWidget(user_data_form,2)
        self.central_widget = QtGui.QWidget()
        self.central_widget.setLayout(layout)

        self.setCentralWidget(self.central_widget)
        self.setWindowTitle("OINK User Manager")
        self.setWindowIcon(QtGui.QIcon(os.path.join('Images','PORK_Icon.png')))
        self.show()

    def mapEvents(self):
        self.users_list_view.itemSelectionChanged.connect(self.changedCurrentEmployee)
        self.dop_checkbox.toggled.connect(self.toggleDOP)
        self.dol_checkbox.toggled.connect(self.toggleDOL)
        self.reset_password_button.clicked.connect(self.resetPassword)
        self.manager_mapping.currentCellChanged.connect(self.populateManagerMappingForm)
        self.add_new_manager_mapping_row.clicked.connect(self.addUpdateManagerMapping)
        self.remove_manager_mapping_row.clicked.connect(self.removeManagerMapping)
        self.save_button.clicked.connect(self.saveSelectedEmployee)
        self.reset_button.clicked.connect(self.changedCurrentEmployee)
        self.add_employee_button.clicked.connect(self.changeMode)
        self.edit_employee_button.clicked.connect(self.changeMode)


    def saveSelectedEmployee(self):
        #First, build a dictionary with the former values.
        #Then, build a dictionary with the new values.
        #pass these dictionaries to a MOSES function.
        employee_id = str(self.employee_id_lineedit.text()).strip()
        employee_name = str(self.employee_name_lineedit.text()).strip()
        employee_email_id = str(self.email_lineedit.text()).strip()
        employee_role = str(self.current_role_combobox.currentText()).strip()
        employee_doj = self.doj_dateedit.date().toPyDate()
        employee_dol = self.dol_dateedit.date().toPyDate() if self.dol_checkbox.isChecked() else "NULL"
        employee_dop = self.dop_dateedit.date().toPyDate() if self.dop_checkbox.isChecked() else "NULL"
        employee_former_role = str(self.former_role_combobox.currentText()).strip() if self.dop_checkbox.isChecked() else "NULL"
        employee_oink_access = str(",".join(self.access_combobox.getCheckedItems())) if len(self.access_combobox.getCheckedItems())>0 else "Pork"

        if self.add_employee_button.isChecked():
            mode = 1
        else:
            mode = 0

        if (employee_id in list(self.employees_data["Employee ID"])) and (mode == 1):
            self.alertMessage("Conflicting User ID","The User ID %s already exists in the system. You can't add another user with that Employee ID."%employee_id)
        else:
            employee_dict = {
                            "Employee ID": employee_id,
                            "Name": employee_name,
                            "Email ID": employee_email_id,
                            "Role": employee_role,
                            "DOJ": employee_doj,
                            "DOL": employee_dol,
                            "Date of Promotion": employee_dop,
                            "Former Role": employee_former_role,
                            "OINK Access Level": ",".join(employee_oink_access) if type(employee_oink_access) == list else employee_oink_access
                        }
            success = MOSES.createOrModifyEmployeeDetails(self.user_id, self.password, employee_dict, mode)
            if success:
                self.refreshData()
                self.initialize()
                self.populateEmployeesList()
                self.alertMessage("Success","Successfully completed the operation")
            else:
                self.alertMessage("Failure","Revenge is just the beginning.")


    def changeMode(self):
        if self.add_employee_button.isChecked():
            self.employee_id_lineedit.setEnabled(True)
        elif self.edit_employee_button.isChecked():
            self.employee_id_lineedit.setEnabled(False)


    def removeManagerMapping(self):
        failure = True
        employee_data = self.getEmployeeData(self.getSelectedEmployee())
        if employee_data is not None:
            employee_id = employee_data["Employee ID"]
            reporting_manager_name = str(self.manager_name_combobox.currentText())
            reporting_manager_data = self.getEmployeeData(reporting_manager_name)
            if reporting_manager_data is not None:
                reporting_manager_id = reporting_manager_data["Employee ID"]
                revision_date = self.manager_effective_dateedit.date().toPyDate()
                MOSES.removeFromManagerMapping(self.user_id, self.password, employee_id, reporting_manager_id, revision_date)
                self.changedCurrentEmployee()
                failure = False
            else:
                failure = True
        else:
            failure = True

        if failure:
            self.alertMessage("Failure","Please select a row that you'd like to delete. If you're having problems, select a cell in another row, then select a cell in the row you'd like to delete.")
        else:
            self.alertMessage("Success","Successfully removed a row from the Manager Mapping Table with the selected parameters.")

    def addUpdateManagerMapping(self):
        employee_id = self.getEmployeeData(self.getSelectedEmployee())["Employee ID"]
        reporting_manager_name = str(self.manager_name_combobox.currentText())
        reporting_manager_id = self.getEmployeeData(reporting_manager_name)["Employee ID"]
        revision_date = self.manager_effective_dateedit.date().toPyDate()
        MOSES.addUpdateManagerMapping(self.user_id, self.password, employee_id, reporting_manager_id, revision_date)
        self.changedCurrentEmployee()
        self.alertMessage("Success","Successfully added a row into the Manager Mapping Table with the selected parameters.")


    def populateManagerMappingForm(self, row=None, column=None):
        rows = sorted(set(index.row() for index in self.manager_mapping.selectedIndexes()))
        manager = self.manager_mapping_data.loc[row]
        name = manager["Reporting Manager Name"]
        date_ = manager["Revision Date"]
        if name is not None:
            self.manager_name_combobox.setCurrentIndex(self.manager_name_combobox.findText(name))
        else:
            self.manager_name_combobox.setCurrentIndex(-1)

        if date_ is not None:
            self.manager_effective_dateedit.setDate(date_)
        else:
            self.manager_effective_dateedit.setDate(datetime.date.today())

    def resetPassword(self):
        current_employee_name = str(self.users_list_view.currentItem().text())
        employee_data = self.getEmployeeData(current_employee_name)
        employee_id = employee_data["Employee ID"]
        MOSES.resetPassword(self.user_id, self.password, employee_id)
        self.alertMessage("Reset Password","Successfully reset %s's password to 'password'!"%(current_employee_name))

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)

    def toggleDOP(self):
        if self.dop_checkbox.isChecked():
            self.dop_dateedit.setEnabled(True)
            self.former_role_combobox.setEnabled(True)
        else:
            self.former_role_combobox.setCurrentIndex(-1)
            self.former_role_combobox.setEnabled(False)
            self.dop_dateedit.setEnabled(False)

    def toggleDOL(self):
        if self.dol_checkbox.isChecked():
            self.dol_dateedit.setEnabled(True)
        else:
            self.dol_dateedit.setEnabled(False)

    def changedCurrentEmployee(self):
        self.showPage(self.getSelectedEmployee())

    def showPage(self, employee_name):
        employee_data = self.getEmployeeData(employee_name)
        if employee_data is not None:
            self.employee_name_lineedit.setText(employee_data["Name"])
            self.employee_id_lineedit.setText(employee_data["Employee ID"])
            self.email_lineedit.setText(employee_data["Email ID"])
            self.doj_dateedit.setDate(employee_data["DOJ"])
            
            if employee_data["DOL"] is None:
                self.dol_checkbox.setChecked(False)
            else:
                self.dol_checkbox.setChecked(True)
                self.dol_dateedit.setDate(employee_data["DOL"])
            self.current_role_combobox.setCurrentIndex(self.current_role_combobox.findText(employee_data["Role"]))
            
            if employee_data["Date of Promotion"] is None:
                self.dop_checkbox.setChecked(False)
                self.former_role_combobox.setCurrentIndex(-1)
            else:
                self.dop_checkbox.setChecked(True)
                self.dop_dateedit.setDate(employee_data["Date of Promotion"])
                self.former_role_combobox.setCurrentIndex(self.former_role_combobox.findText(employee_data["Former Role"]))
            self.access_combobox.clearSelection()
            access_level = employee_data["Access Level"] if "," not in employee_data["Access Level"] else employee_data["Access Level"].split(",")
            self.access_combobox.select(access_level)

            self.toggleDOP()
            self.toggleDOL()

            self.manager_mapping_data = MOSES.getManagerMappingTable(self.user_id, self.password, employee_data["Employee ID"])
            self.manager_mapping.showDataFrame(self.manager_mapping_data)
            self.manager_mapping.verticalHeader().setStretchLastSection(False)
            self.manager_mapping.verticalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
            self.manager_mapping.verticalHeader().setVisible(True)

            self.manager_mapping.horizontalHeader().setStretchLastSection(True)
            self.manager_mapping.horizontalHeader().setResizeMode(QtGui.QHeaderView.ResizeToContents)
            self.manager_mapping.horizontalHeader().setResizeMode(QtGui.QHeaderView.Interactive)
            self.manager_mapping.horizontalHeader().setVisible(True)
            self.manager_mapping.horizontalHeader().setStretchLastSection(False)
            self.manager_name_combobox.setCurrentIndex(-1)

    def getSelectedEmployee(self):
        return str(self.users_list_view.currentItem().text())

    def getEmployeeData(self, employee_name):
        location_match = self.employees_data["Name"] == employee_name
        if True in set(location_match):
            employee_id = list(self.employees_data[location_match]["Employee ID"])[0]
            employee_name = list(self.employees_data[location_match]["Name"])[0]
            employee_email_id = list(self.employees_data[location_match]["Email ID"])[0]
            employee_doj = list(self.employees_data[location_match]["DOJ"])[0]
            employee_dol = list(self.employees_data[location_match]["DOL"])[0]
            employee_role = list(self.employees_data[location_match]["Role"])[0]
            employee_dop = list(self.employees_data[location_match]["Date of Promotion"])[0]
            employee_former_role = list(self.employees_data[location_match]["Former Role"])[0]
            employee_oink_access = list(self.employees_data[location_match]["OINK Access Level"])[0]

            data = {
                    "Employee ID": employee_id,
                    "Name": employee_name,
                    "Email ID": employee_email_id,
                    "DOJ": employee_doj,
                    "DOL": employee_dol,
                    "Role": employee_role,
                    "Date of Promotion": employee_dop,
                    "Former Role": employee_former_role,
                    "Access Level": employee_oink_access
                }
        else:
            data = None
        return data


    def initialize(self):
        employees_list = list(set(self.employees_data["Name"]))
        employees_list.sort()
        self.users_list_view.clear()
        self.users_list_view.addItems(employees_list)
        self.manager_name_combobox.clear()
        self.manager_name_combobox.addItems(employees_list)
        roles = list(set(self.employees_data["Role"]))
        roles.sort()
        self.current_role_combobox.addItems(roles)
        self.former_role_combobox.addItems(roles)
        self.toggleDOL()
        self.toggleDOP()
        self.manager_name_combobox.setCurrentIndex(-1)
        self.manager_effective_dateedit.setDate(datetime.date.today())
        self.edit_employee_button.setChecked(True)
        self.employee_id_lineedit.setEnabled(False)
        self.users_list_view.setCurrentRow(0)


    def populateEmployeesList(self):
        pass
    
    def addEmployee(self):
        pass

    def modifyEmployee(self):
        pass

    def resetEmployeePassword(self):
        pass

    def promoteEmployee(self):
        pass

    def populateReportingManagerList(self):
        pass
Ejemplo n.º 21
0
    def createUI(self):
        self.date_label = QtGui.QLabel("Date(s):")
        self.start_date = FormattedDateEdit()
        self.end_date = FormattedDateEdit()

        self.employees_label = QtGui.QLabel("Employees:")
        self.employees_selection_box = CheckableComboBox("Employees")
        self.all_button = QtGui.QPushButton("Select All")
        self.clear_button = QtGui.QPushButton("Clear")

        self.refresh_table_button = QtGui.QPushButton("Refresh Table")
        self.approve_selected_button = QtGui.QPushButton("Approved")
        self.approve_selected_button.setCheckable(True)
        self.reject_selected_button = QtGui.QPushButton("Rejected")
        self.reject_selected_button.setCheckable(True)
        self.pending_selected_button = QtGui.QPushButton("Pending")
        self.pending_selected_button.setCheckable(True)

        self.button_group = QtGui.QButtonGroup()
        self.button_group.addButton(self.approve_selected_button)
        self.button_group.addButton(self.reject_selected_button)
        self.button_group.addButton(self.pending_selected_button)
        self.button_group.setExclusive(True)

        self.approval_comment_label = QtGui.QLabel("Approval\\Rejection Comment:")
        self.rejection_comment_lineedit = QtGui.QLineEdit()

        self.leave_table = CopiableQTableWidget(0, 0)

        self.status_label = QtGui.QLabel("Status")
        self.status_combobox = QtGui.QComboBox()
        self.status_combobox.addItems(["Working","Leave"])
        self.comment_label = QtGui.QLabel("Comment")
        self.comment_lineedit = QtGui.QLineEdit()
        self.save_selected_button = QtGui.QPushButton("Save")
        self.save_selected_button.setEnabled(False)
        self.save_all_button = QtGui.QPushButton("Save All")

        row_1 = QtGui.QHBoxLayout()
        row_1.addWidget(self.date_label,0)
        row_1.addWidget(self.start_date,0)
        row_1.addWidget(self.end_date,0)
        row_1.addWidget(self.employees_label,0)
        row_1.addWidget(self.employees_selection_box,0)
        row_1.addWidget(self.all_button,0)
        row_1.addWidget(self.clear_button,0)

        self.relaxation_label = QtGui.QLabel("Relaxation")
        self.relaxation_spinbox = QtGui.QDoubleSpinBox()
        self.relaxation_spinbox.setSuffix("%")

        row_2 = QtGui.QHBoxLayout()
        row_2.addWidget(self.status_label, 0)
        row_2.addWidget(self.status_combobox, 0)
        row_2.addWidget(self.relaxation_label, 0)
        row_2.addWidget(self.relaxation_spinbox, 0)
        row_2.addWidget(self.comment_label, 0)
        row_2.addWidget(self.comment_lineedit, 0)

        row_3 = QtGui.QHBoxLayout()
        row_3.addWidget(self.approval_comment_label,0)
        row_3.addWidget(self.rejection_comment_lineedit,0)
        row_3.addWidget(self.approve_selected_button,0)
        row_3.addWidget(self.reject_selected_button,0)
        row_3.addWidget(self.pending_selected_button,0)
        row_3.addWidget(self.save_selected_button,0)
        row_3.addWidget(self.save_all_button,0)
        row_3.addWidget(self.refresh_table_button,0)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_1)
        layout.addLayout(row_2)
        layout.addLayout(row_3)
        layout.addWidget(self.leave_table)

        self.setLayout(layout)
        self.setWindowTitle("Leaves Manager")
        self.setWindowIcon(QtGui.QIcon(os.path.join(MOSES.getPathToImages(),"PORK_Icon.png")))
        self.show()
Ejemplo n.º 22
0
class CategorySelector(QtGui.QVBoxLayout):
    changedCategorySelection = QtCore.pyqtSignal()

    def __init__(self, category_tree, *args, **kwargs):
        super(CategorySelector, self).__init__(*args, **kwargs)
        self.category_tree = category_tree
        self.category_tree_headers = [
            "BU", "Super-Category", "Category", "Sub-Category", "Vertical"
        ]
        self.createUI()
        self.populateAll()
        self.mapEvents()

    def createUI(self):
        self.label = QtGui.QLabel("Categories:")
        self.bu_combo_box = CheckableComboBox("BU")
        self.super_category_combo_box = CheckableComboBox("Super-Category")
        self.category_combo_box = CheckableComboBox("Category")
        self.sub_category_combo_box = CheckableComboBox("Sub-Category")
        self.vertical_combo_box = CheckableComboBox("Vertical")
        self.category_finder = CategoryFinder(self.category_tree)
        self.clear_button = QtGui.QPushButton("Clear\nFilters")
        row_1 = QtGui.QHBoxLayout()
        row_1.addWidget(self.label, 0)
        row_1.addWidget(self.bu_combo_box, 1)
        row_1.addWidget(self.super_category_combo_box, 1)
        row_1.addWidget(self.category_combo_box, 1)
        row_2 = QtGui.QHBoxLayout()
        row_2.addWidget(self.sub_category_combo_box)
        row_2.addWidget(self.vertical_combo_box)
        row_2.addStretch(2)
        row_2.addWidget(self.clear_button)

        self.addLayout(row_1)
        self.addLayout(row_2)
        self.addLayout(self.category_finder)

    def mapEvents(self):
        self.category_finder.pickRow.connect(self.selectRow)
        self.vertical_combo_box.changedSelection.connect(self.changedVerticals)
        self.sub_category_combo_box.changedSelection.connect(
            self.changedSubCategories)
        self.category_combo_box.changedSelection.connect(
            self.changedCategories)
        self.super_category_combo_box.changedSelection.connect(
            self.changedSuperCategories)
        self.clear_button.clicked.connect(self.clearFilters)

        self.vertical_combo_box.changedSelection.connect(
            self.changedCategorySelection)
        self.sub_category_combo_box.changedSelection.connect(
            self.changedCategorySelection)
        self.category_combo_box.changedSelection.connect(
            self.changedCategorySelection)
        self.super_category_combo_box.changedSelection.connect(
            self.changedCategorySelection)
        self.bu_combo_box.changedSelection.connect(
            self.changedCategorySelection)

    def populateAll(self):
        #Populate the values
        bus = list(set(self.category_tree["BU"]))
        bus.sort()
        super_categories = list(set(self.category_tree["Super-Category"]))
        super_categories.sort()
        categories = list(set(self.category_tree["Category"]))
        categories.sort()
        sub_categories = list(set(self.category_tree["Sub-Category"]))
        sub_categories.sort()
        verticals = list(set(self.category_tree["Vertical"]))
        verticals.sort()

        self.bu_combo_box.clear()
        self.bu_combo_box.addItems(bus)
        self.super_category_combo_box.clear()
        self.super_category_combo_box.addItems(super_categories)
        self.category_combo_box.clear()
        self.category_combo_box.addItems(categories)
        self.sub_category_combo_box.clear()
        self.sub_category_combo_box.addItems(sub_categories)
        self.vertical_combo_box.clear()
        self.vertical_combo_box.addItems(verticals)

    def getSelectedCategories(self):
        selected_categories_data_frame = []
        return selected_categories_data_frame

    def selectRow(self, row_dict):
        self.bu_combo_box.select(row_dict["BU"])
        self.super_category_combo_box.select(row_dict["Super-Category"])
        self.category_combo_box.select(row_dict["Category"])
        self.sub_category_combo_box.select(row_dict["Sub-Category"])
        self.vertical_combo_box.select(row_dict["Vertical"])

    def changedSuperCategories(self):
        selected_super_categories = self.super_category_combo_box.getCheckedItems(
        )
        required_bus = list(
            set(self.category_tree[self.category_tree["Super-Category"].isin(
                selected_super_categories)]["BU"]))
        for bu in required_bus:
            self.bu_combo_box.select(bu)

    def changedCategories(self):
        selected_categories = self.category_combo_box.getCheckedItems()
        required_super_categories = list(
            set(self.category_tree[self.category_tree["Category"].isin(
                selected_categories)]["Super-Category"]))
        for super_category in required_super_categories:
            self.super_category_combo_box.select(super_category)

    def changedSubCategories(self):
        selected_sub_categories = self.sub_category_combo_box.getCheckedItems()
        required_categories = list(
            set(self.category_tree[self.category_tree["Sub-Category"].isin(
                selected_sub_categories)]["Category"]))
        for category in required_categories:
            self.category_combo_box.select(category)

    def changedVerticals(self):
        selected_verticals = self.vertical_combo_box.getCheckedItems()
        required_sub_categories = list(
            set(self.category_tree[self.category_tree["Vertical"].isin(
                selected_verticals)]["Sub-Category"]))
        for sub_category in required_sub_categories:
            self.sub_category_combo_box.select(sub_category)

    def clearFilters(self):
        self.bu_combo_box.clearSelection()
        self.super_category_combo_box.clearSelection()
        self.category_combo_box.clearSelection()
        self.sub_category_combo_box.clearSelection()
        self.vertical_combo_box.clearSelection()

    def getFilters(self):
        #First, get the checked verticals.
        verticals = self.vertical_combo_box.getCheckedItems()
        vertical_filter_data_frame = self.category_tree[
            self.category_tree["Vertical"].isin(verticals)]

        sub_categories = self.sub_category_combo_box.getCheckedItems()
        accounted_sub_categories = list(
            set(vertical_filter_data_frame["Sub-Category"]))
        unaccounted_sub_categories = [
            sub_category for sub_category in sub_categories
            if sub_category not in accounted_sub_categories
        ]
        if len(unaccounted_sub_categories) > 0:
            #print "Found unaccounted_sub_categories", unaccounted_sub_categories
            sub_category_filter_data_frame = self.category_tree[
                self.category_tree["Sub-Category"].isin(
                    unaccounted_sub_categories)]
            sub_cat_vert_filter_data_frame = pd.concat(
                [sub_category_filter_data_frame, vertical_filter_data_frame])
        else:
            sub_cat_vert_filter_data_frame = vertical_filter_data_frame

        categories = self.category_combo_box.getCheckedItems()
        accounted_categories = list(
            set(sub_cat_vert_filter_data_frame["Category"]))
        unaccounted_categories = [
            category for category in categories
            if category not in accounted_categories
        ]
        if len(unaccounted_categories) > 0:
            #print "Found unaccounted_categories", unaccounted_categories
            category_filter_data_frame = self.category_tree[
                self.category_tree["Category"].isin(unaccounted_categories)]
            cat_sub_cat_vert_filter_data_frame = pd.concat(
                [category_filter_data_frame, sub_cat_vert_filter_data_frame])
        else:
            cat_sub_cat_vert_filter_data_frame = sub_cat_vert_filter_data_frame

        super_categories = self.super_category_combo_box.getCheckedItems()
        accounted_super_categories = list(
            set(cat_sub_cat_vert_filter_data_frame["Super-Category"]))
        unaccounted_super_categories = [
            super_category for super_category in super_categories
            if super_category not in accounted_super_categories
        ]
        if len(unaccounted_super_categories) > 0:
            #print "Found unaccounted_super_categories", unaccounted_super_categories
            super_category_filter_data_frame = self.category_tree[
                self.category_tree["Super-Category"].isin(
                    unaccounted_super_categories)]
            supcat_cat_sub_cat_vert_filter_data_frame = pd.concat([
                super_category_filter_data_frame,
                cat_sub_cat_vert_filter_data_frame
            ])
        else:
            supcat_cat_sub_cat_vert_filter_data_frame = cat_sub_cat_vert_filter_data_frame

        bus = self.bu_combo_box.getCheckedItems()
        accounted_bus = list(
            set(supcat_cat_sub_cat_vert_filter_data_frame["BU"]))
        unaccounted_bus = [bu for bu in bus if bu not in accounted_bus]
        if len(unaccounted_bus) > 0:
            #print "Found unaccounted_bus", unaccounted_bus
            bu_filter_data_frame = self.category_tree[
                self.category_tree["BU"].isin(unaccounted_bus)]
            filter_data_frame = pd.concat([
                bu_filter_data_frame, supcat_cat_sub_cat_vert_filter_data_frame
            ])
        else:
            filter_data_frame = supcat_cat_sub_cat_vert_filter_data_frame
        return filter_data_frame.drop_duplicates(
            subset=self.category_tree_headers)[self.category_tree_headers]
Ejemplo n.º 23
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1327, 481)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.centralWidget.setObjectName("centralWidget")
        self.pushButton = QtWidgets.QPushButton(self.centralWidget)
        self.pushButton.setGeometry(QtCore.QRect(10, 45, 202, 35))
        self.pushButton.setObjectName("pushButton")
        self.pbSwitchMap = QtWidgets.QPushButton(self.centralWidget)
        self.pbSwitchMap.setGeometry(QtCore.QRect(10, 131, 101, 35))
        self.pbSwitchMap.setObjectName("pbSwitchMap")
        self.groupBoxShowGeneral = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxShowGeneral.setGeometry(QtCore.QRect(11, 169, 91, 125))
        self.groupBoxShowGeneral.setAutoFillBackground(True)
        self.groupBoxShowGeneral.setObjectName("groupBoxShowGeneral")
        self.cbShowMarkers = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.cbShowMarkers.setGeometry(QtCore.QRect(10, 20, 70, 17))
        self.cbShowMarkers.setObjectName("cbShowMarkers")
        self.cbShowConnections = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.cbShowConnections.setGeometry(QtCore.QRect(10, 40, 81, 17))
        self.cbShowConnections.setObjectName("cbShowConnections")
        self.cbShowInfo = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.cbShowInfo.setGeometry(QtCore.QRect(10, 60, 81, 17))
        self.cbShowInfo.setObjectName("cbShowInfo")
        self.pbToggleBounce = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.pbToggleBounce.setGeometry(QtCore.QRect(10, 100, 71, 21))
        self.pbToggleBounce.setObjectName("pbToggleBounce")
        self.pbToggleHeatmap = QtWidgets.QCheckBox(self.groupBoxShowGeneral)
        self.pbToggleHeatmap.setGeometry(QtCore.QRect(10, 80, 71, 21))
        self.pbToggleHeatmap.setObjectName("pbToggleHeatmap")
        self.groupBoxShowNodes = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxShowNodes.setGeometry(QtCore.QRect(110, 170, 101, 124))
        self.groupBoxShowNodes.setAutoFillBackground(True)
        self.groupBoxShowNodes.setObjectName("groupBoxShowNodes")
        self.cbShowGood = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowGood.setGeometry(QtCore.QRect(10, 20, 70, 17))
        self.cbShowGood.setObjectName("cbShowGood")
        self.cbShowBad = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowBad.setGeometry(QtCore.QRect(10, 60, 70, 17))
        self.cbShowBad.setObjectName("cbShowBad")
        self.cbShowPing = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowPing.setGeometry(QtCore.QRect(10, 80, 71, 17))
        self.cbShowPing.setObjectName("cbShowPing")
        self.cbShowUnresolved = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowUnresolved.setGeometry(QtCore.QRect(10, 40, 81, 17))
        self.cbShowUnresolved.setObjectName("cbShowUnresolved")
        self.cbShowKilled = QtWidgets.QCheckBox(self.groupBoxShowNodes)
        self.cbShowKilled.setGeometry(QtCore.QRect(10, 100, 71, 17))
        self.cbShowKilled.setObjectName("cbShowKilled")
        self.groupBoxStatusHosts = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxStatusHosts.setGeometry(QtCore.QRect(219, 40, 111, 38))
        self.groupBoxStatusHosts.setObjectName("groupBoxStatusHosts")
        self.labelHostsSolved = QtWidgets.QLabel(self.groupBoxStatusHosts)
        self.labelHostsSolved.setGeometry(QtCore.QRect(10, 15, 61, 16))
        self.labelHostsSolved.setObjectName("labelHostsSolved")
        self.statusHostsSolved = QtWidgets.QLabel(self.groupBoxStatusHosts)
        self.statusHostsSolved.setGeometry(QtCore.QRect(76, 13, 31, 20))
        self.statusHostsSolved.setObjectName("statusHostsSolved")
        self.groupBoxShowConnections = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxShowConnections.setGeometry(QtCore.QRect(
            11, 298, 91, 121))
        self.groupBoxShowConnections.setAutoFillBackground(True)
        self.groupBoxShowConnections.setObjectName("groupBoxShowConnections")
        self.cbShowGoodConn = QtWidgets.QCheckBox(self.groupBoxShowConnections)
        self.cbShowGoodConn.setGeometry(QtCore.QRect(10, 20, 70, 17))
        self.cbShowGoodConn.setObjectName("cbShowGoodConn")
        self.cbShowUnresolvedConn = QtWidgets.QCheckBox(
            self.groupBoxShowConnections)
        self.cbShowUnresolvedConn.setGeometry(QtCore.QRect(10, 40, 81, 17))
        self.cbShowUnresolvedConn.setObjectName("cbShowUnresolvedConn")
        self.cbShowBadConn = QtWidgets.QCheckBox(self.groupBoxShowConnections)
        self.cbShowBadConn.setGeometry(QtCore.QRect(10, 60, 70, 17))
        self.cbShowBadConn.setObjectName("cbShowBadConn")
        self.cbShowConnectionsActive = QtWidgets.QCheckBox(
            self.groupBoxShowConnections)
        self.cbShowConnectionsActive.setGeometry(QtCore.QRect(10, 80, 81, 17))
        self.cbShowConnectionsActive.setObjectName("cbShowConnectionsActive")
        self.cbShowKilledConn = QtWidgets.QCheckBox(
            self.groupBoxShowConnections)
        self.cbShowKilledConn.setGeometry(QtCore.QRect(10, 99, 81, 17))
        self.cbShowKilledConn.setObjectName("cbShowKilledConn")
        self.pbOpenFile = QtWidgets.QPushButton(self.centralWidget)
        self.pbOpenFile.setGeometry(QtCore.QRect(10, 88, 202, 35))
        self.pbOpenFile.setObjectName("pbOpenFile")
        self.groupBoxOptions = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxOptions.setGeometry(QtCore.QRect(110, 298, 101, 61))
        self.groupBoxOptions.setAutoFillBackground(True)
        self.groupBoxOptions.setObjectName("groupBoxOptions")
        self.cbPlot = QtWidgets.QCheckBox(self.groupBoxOptions)
        self.cbPlot.setGeometry(QtCore.QRect(10, 18, 70, 17))
        self.cbPlot.setChecked(False)
        self.cbPlot.setObjectName("cbPlot")
        self.cbSound = QtWidgets.QCheckBox(self.groupBoxOptions)
        self.cbSound.setGeometry(QtCore.QRect(10, 38, 70, 17))
        self.cbSound.setChecked(False)
        self.cbSound.setObjectName("cbSound")
        self.comboBoxInterface = QtWidgets.QComboBox(self.centralWidget)
        self.comboBoxInterface.setGeometry(QtCore.QRect(11, 7, 319, 31))
        self.comboBoxInterface.setObjectName("comboBoxInterface")
        self.groupBox = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox.setGeometry(QtCore.QRect(220, 262, 111, 97))
        self.groupBox.setAutoFillBackground(False)
        self.groupBox.setStyleSheet("background-color: rgb(255, 247, 211);")
        self.groupBox.setObjectName("groupBox")
        self.cbKillBad = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillBad.setGeometry(QtCore.QRect(10, 36, 70, 17))
        self.cbKillBad.setChecked(False)
        self.cbKillBad.setObjectName("cbKillBad")
        self.cbKillNone = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillNone.setGeometry(QtCore.QRect(10, 17, 70, 17))
        self.cbKillNone.setChecked(True)
        self.cbKillNone.setObjectName("cbKillNone")
        self.cbKillAll = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillAll.setGeometry(QtCore.QRect(10, 75, 70, 17))
        self.cbKillAll.setChecked(False)
        self.cbKillAll.setObjectName("cbKillAll")
        self.cbKillBandwidth = QtWidgets.QRadioButton(self.groupBox)
        self.cbKillBandwidth.setGeometry(QtCore.QRect(10, 56, 91, 17))
        self.cbKillBandwidth.setChecked(False)
        self.cbKillBandwidth.setObjectName("cbKillBandwidth")
        self.groupBox_2 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_2.setGeometry(QtCore.QRect(219, 137, 111, 55))
        self.groupBox_2.setObjectName("groupBox_2")
        self.statusNodes = QtWidgets.QLabel(self.groupBox_2)
        self.statusNodes.setGeometry(QtCore.QRect(75, 14, 31, 20))
        self.statusNodes.setObjectName("statusNodes")
        self.labelConnections_2 = QtWidgets.QLabel(self.groupBox_2)
        self.labelConnections_2.setGeometry(QtCore.QRect(9, 16, 61, 16))
        self.labelConnections_2.setObjectName("labelConnections_2")
        self.statusBadNodes = QtWidgets.QLabel(self.groupBox_2)
        self.statusBadNodes.setGeometry(QtCore.QRect(75, 31, 31, 20))
        self.statusBadNodes.setObjectName("statusBadNodes")
        self.labelBadNodes = QtWidgets.QLabel(self.groupBox_2)
        self.labelBadNodes.setGeometry(QtCore.QRect(9, 33, 61, 16))
        self.labelBadNodes.setObjectName("labelBadNodes")
        self.groupBox_3 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_3.setGeometry(QtCore.QRect(220, 194, 111, 61))
        self.groupBox_3.setObjectName("groupBox_3")
        self.statusRxBytes = QtWidgets.QLabel(self.groupBox_3)
        self.statusRxBytes.setGeometry(QtCore.QRect(56, 34, 51, 20))
        self.statusRxBytes.setObjectName("statusRxBytes")
        self.labelRXBytes = QtWidgets.QLabel(self.groupBox_3)
        self.labelRXBytes.setGeometry(QtCore.QRect(10, 36, 41, 16))
        self.labelRXBytes.setObjectName("labelRXBytes")
        self.labelTXBytes = QtWidgets.QLabel(self.groupBox_3)
        self.labelTXBytes.setGeometry(QtCore.QRect(10, 15, 41, 16))
        self.labelTXBytes.setObjectName("labelTXBytes")
        self.statusTxBytes = QtWidgets.QLabel(self.groupBox_3)
        self.statusTxBytes.setGeometry(QtCore.QRect(56, 13, 51, 20))
        self.statusTxBytes.setObjectName("statusTxBytes")
        self.groupBox_4 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_4.setGeometry(QtCore.QRect(219, 80, 111, 55))
        self.groupBox_4.setObjectName("groupBox_4")
        self.statusConnections = QtWidgets.QLabel(self.groupBox_4)
        self.statusConnections.setGeometry(QtCore.QRect(75, 12, 31, 20))
        self.statusConnections.setObjectName("statusConnections")
        self.labelConnections = QtWidgets.QLabel(self.groupBox_4)
        self.labelConnections.setGeometry(QtCore.QRect(9, 14, 61, 16))
        self.labelConnections.setObjectName("labelConnections")
        self.labelKilledNodes = QtWidgets.QLabel(self.groupBox_4)
        self.labelKilledNodes.setGeometry(QtCore.QRect(10, 31, 60, 16))
        self.labelKilledNodes.setObjectName("labelKilledNodes")
        self.statusKilledNodes = QtWidgets.QLabel(self.groupBox_4)
        self.statusKilledNodes.setGeometry(QtCore.QRect(75, 31, 30, 20))
        self.statusKilledNodes.setObjectName("statusKilledNodes")
        self.listWidgetKilledProcesses = QtWidgets.QListWidget(
            self.centralWidget)
        self.listWidgetKilledProcesses.setGeometry(
            QtCore.QRect(338, 23, 131, 161))
        self.listWidgetKilledProcesses.setObjectName(
            "listWidgetKilledProcesses")
        self.label = QtWidgets.QLabel(self.centralWidget)
        self.label.setGeometry(QtCore.QRect(339, 3, 91, 16))
        self.label.setObjectName("label")
        self.listWidgetNodes = QtWidgets.QListWidget(self.centralWidget)
        self.listWidgetNodes.setGeometry(QtCore.QRect(477, 23, 531, 447))
        self.listWidgetNodes.setObjectName("listWidgetNodes")
        self.label_2 = QtWidgets.QLabel(self.centralWidget)
        self.label_2.setGeometry(QtCore.QRect(478, 4, 91, 16))
        self.label_2.setObjectName("label_2")
        self.pbGenerateReport = QtWidgets.QPushButton(self.centralWidget)
        self.pbGenerateReport.setGeometry(QtCore.QRect(530, 2, 161, 21))
        self.pbGenerateReport.setStyleSheet(
            "background-color: rgb(225, 229, 255);")
        self.pbGenerateReport.setObjectName("pbGenerateReport")
        self.groupBoxPing = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBoxPing.setGeometry(QtCore.QRect(338, 298, 131, 121))
        self.groupBoxPing.setTitle("")
        self.groupBoxPing.setObjectName("groupBoxPing")
        self.cbPingIP = QtWidgets.QRadioButton(self.groupBoxPing)
        self.cbPingIP.setGeometry(QtCore.QRect(90, 43, 31, 17))
        self.cbPingIP.setChecked(True)
        self.cbPingIP.setObjectName("cbPingIP")
        self.cbPingAll = QtWidgets.QRadioButton(self.groupBoxPing)
        self.cbPingAll.setGeometry(QtCore.QRect(10, 43, 81, 17))
        self.cbPingAll.setChecked(False)
        self.cbPingAll.setObjectName("cbPingAll")
        self.pbPing = QtWidgets.QPushButton(self.groupBoxPing)
        self.pbPing.setGeometry(QtCore.QRect(9, 92, 113, 24))
        self.pbPing.setObjectName("pbPing")
        self.groupBox_5 = QtWidgets.QGroupBox(self.groupBoxPing)
        self.groupBox_5.setGeometry(QtCore.QRect(0, -4, 131, 25))
        self.groupBox_5.setTitle("")
        self.groupBox_5.setObjectName("groupBox_5")
        self.cbPingAuto = QtWidgets.QCheckBox(self.groupBox_5)
        self.cbPingAuto.setGeometry(QtCore.QRect(86, 5, 41, 17))
        self.cbPingAuto.setChecked(True)
        self.cbPingAuto.setObjectName("cbPingAuto")
        self.comboPing = QtWidgets.QComboBox(self.groupBoxPing)
        self.comboPing.setGeometry(QtCore.QRect(10, 65, 111, 22))
        self.comboPing.setObjectName("comboPing")
        self.cbPingRandom = QtWidgets.QRadioButton(self.groupBoxPing)
        self.cbPingRandom.setGeometry(QtCore.QRect(10, 25, 121, 17))
        self.cbPingRandom.setChecked(False)
        self.cbPingRandom.setObjectName("cbPingRandom")
        self.label_3 = QtWidgets.QLabel(self.centralWidget)
        self.label_3.setGeometry(QtCore.QRect(349, 298, 81, 16))
        self.label_3.setObjectName("label_3")
        self.groupBox_6 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_6.setGeometry(QtCore.QRect(339, 189, 131, 101))
        self.groupBox_6.setStyleSheet("background-color: rgb(255, 247, 211);")
        self.groupBox_6.setObjectName("groupBox_6")
        self.comboKill = QtWidgets.QComboBox(self.groupBox_6)
        self.comboKill.setGeometry(QtCore.QRect(10, 43, 113, 22))
        self.comboKill.setObjectName("comboKill")
        self.pbKill = QtWidgets.QPushButton(self.groupBox_6)
        self.pbKill.setGeometry(QtCore.QRect(9, 72, 113, 24))
        self.pbKill.setObjectName("pbKill")
        self.cbKillAllNow = QtWidgets.QRadioButton(self.groupBox_6)
        self.cbKillAllNow.setGeometry(QtCore.QRect(10, 20, 41, 17))
        self.cbKillAllNow.setChecked(False)
        self.cbKillAllNow.setObjectName("cbKillAllNow")
        self.cbKillIP = QtWidgets.QRadioButton(self.groupBox_6)
        self.cbKillIP.setGeometry(QtCore.QRect(91, 20, 31, 17))
        self.cbKillIP.setChecked(True)
        self.cbKillIP.setObjectName("cbKillIP")
        self.cbKillBadNow = QtWidgets.QRadioButton(self.groupBox_6)
        self.cbKillBadNow.setGeometry(QtCore.QRect(50, 20, 41, 17))
        self.cbKillBadNow.setChecked(False)
        self.cbKillBadNow.setObjectName("cbKillBadNow")
        self.groupBox_7 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_7.setGeometry(QtCore.QRect(110, 368, 221, 51))
        self.groupBox_7.setStyleSheet("background-color: rgb(255, 247, 211);")
        self.groupBox_7.setObjectName("groupBox_7")
        self.cbBlockBadInFirewall = QtWidgets.QCheckBox(self.groupBox_7)
        self.cbBlockBadInFirewall.setGeometry(QtCore.QRect(8, 19, 211, 17))
        self.cbBlockBadInFirewall.setChecked(False)
        self.cbBlockBadInFirewall.setObjectName("cbBlockBadInFirewall")
        self.ptSelectedIP = QtWidgets.QPlainTextEdit(self.centralWidget)
        self.ptSelectedIP.setEnabled(True)
        self.ptSelectedIP.setGeometry(QtCore.QRect(1016, 23, 301, 447))
        self.ptSelectedIP.setToolTip("")
        self.ptSelectedIP.setObjectName("ptSelectedIP")
        self.cbAutoScrollNodes = QtWidgets.QCheckBox(self.centralWidget)
        self.cbAutoScrollNodes.setGeometry(QtCore.QRect(700, 3, 70, 17))
        self.cbAutoScrollNodes.setChecked(True)
        self.cbAutoScrollNodes.setObjectName("cbAutoScrollNodes")
        self.groupBox_8 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_8.setGeometry(QtCore.QRect(11, 420, 458, 51))
        self.groupBox_8.setObjectName("groupBox_8")
        self.comboShowHost = CheckableComboBox(self.centralWidget)
        self.comboShowHost.setGeometry(QtCore.QRect(20, 439, 439, 22))
        self.comboShowHost.setObjectName("comboShowHost")
        self.lblStatus = QtWidgets.QLabel(self.centralWidget)
        self.lblStatus.setGeometry(QtCore.QRect(1301, 1, 16, 20))
        self.lblStatus.setToolTip("")
        self.lblStatus.setToolTipDuration(-1)
        self.lblStatus.setStatusTip("")
        self.lblStatus.setStyleSheet("")
        self.lblStatus.setObjectName("lblStatus")
        self.label_4 = QtWidgets.QLabel(self.centralWidget)
        self.label_4.setGeometry(QtCore.QRect(1256, 2, 41, 16))
        self.label_4.setToolTip("")
        self.label_4.setToolTipDuration(5)
        self.label_4.setObjectName("label_4")
        self.statusHostsRequested = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsRequested.setGeometry(QtCore.QRect(280, 500, 31, 20))
        self.statusHostsRequested.setObjectName("statusHostsRequested")
        self.labelHostsRequested = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsRequested.setGeometry(QtCore.QRect(214, 502, 61, 16))
        self.labelHostsRequested.setObjectName("labelHostsRequested")
        self.statusHostsFailed = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsFailed.setGeometry(QtCore.QRect(280, 530, 31, 20))
        self.statusHostsFailed.setObjectName("statusHostsFailed")
        self.labelHostsFailed = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsFailed.setGeometry(QtCore.QRect(214, 532, 61, 16))
        self.labelHostsFailed.setObjectName("labelHostsFailed")
        self.statusHostsFailedOld = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsFailedOld.setGeometry(QtCore.QRect(280, 560, 31, 20))
        self.statusHostsFailedOld.setObjectName("statusHostsFailedOld")
        self.labelHostsFailedOld = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsFailedOld.setGeometry(QtCore.QRect(214, 562, 61, 16))
        self.labelHostsFailedOld.setObjectName("labelHostsFailedOld")
        self.statusHostsResolvedOld = QtWidgets.QLabel(self.centralWidget)
        self.statusHostsResolvedOld.setGeometry(QtCore.QRect(280, 590, 31, 20))
        self.statusHostsResolvedOld.setObjectName("statusHostsResolvedOld")
        self.labelHostsResolvedOld = QtWidgets.QLabel(self.centralWidget)
        self.labelHostsResolvedOld.setGeometry(QtCore.QRect(214, 592, 61, 16))
        self.labelHostsResolvedOld.setObjectName("labelHostsResolvedOld")
        self.pbShowMap = QtWidgets.QPushButton(self.centralWidget)
        self.pbShowMap.setGeometry(QtCore.QRect(111, 131, 101, 35))
        self.pbShowMap.setStyleSheet("background-color: rgb(225, 229, 255);")
        self.pbShowMap.setObjectName("pbShowMap")
        self.pbStartIpNetInfo = QtWidgets.QPushButton(self.centralWidget)
        self.pbStartIpNetInfo.setGeometry(QtCore.QRect(1015, 2, 101, 21))
        self.pbStartIpNetInfo.setStyleSheet(
            "background-color: rgb(225, 229, 255);")
        self.pbStartIpNetInfo.setObjectName("pbStartIpNetInfo")
        self.groupBox_9 = QtWidgets.QGroupBox(self.centralWidget)
        self.groupBox_9.setGeometry(QtCore.QRect(1120, 2, 101, 21))
        self.groupBox_9.setTitle("")
        self.groupBox_9.setObjectName("groupBox_9")
        self.rbAllIpInfos = QtWidgets.QRadioButton(self.groupBox_9)
        self.rbAllIpInfos.setGeometry(QtCore.QRect(5, 2, 31, 17))
        self.rbAllIpInfos.setChecked(True)
        self.rbAllIpInfos.setObjectName("rbAllIpInfos")
        self.rbSelectedIpInfos = QtWidgets.QRadioButton(self.groupBox_9)
        self.rbSelectedIpInfos.setGeometry(QtCore.QRect(39, 2, 61, 17))
        self.rbSelectedIpInfos.setObjectName("rbSelectedIpInfos")
        MainWindow.setCentralWidget(self.centralWidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Ejemplo n.º 24
0
class FarmHand(QtGui.QWidget):
    def __init__(self, user_id, password):
        super(FarmHand,self).__init__()
        self.user_id, self.password = user_id, password
        self.createUI()
        self.mapEvents()
        self.clip = QtGui.QApplication.clipboard()
        self.show()
        
    
    def createUI(self):
        self.start_date_edit = QtGui.QDateEdit()
        self.start_date_edit.setMinimumDate(datetime.date(2015,1,1))
        self.start_date_edit.setToolTip("Select a start date.")
        self.start_date_edit.setMaximumDate(datetime.date.today())
        self.end_date_edit = QtGui.QDateEdit()
        self.end_date_edit.setToolTip("Select an end date.")
        self.end_date_edit.setMinimumDate(datetime.date(2015,1,1))
        self.end_date_edit.setMaximumDate(datetime.date.today())
        self.start_date_edit.setCalendarPopup(True)
        self.end_date_edit.setCalendarPopup(True)
        self.start_date_label = QtGui.QLabel("Select a start date:")
        self.end_date_label = QtGui.QLabel("Select an end date:")
        self.type_combo_box = CheckableComboBox("Article Type")
        self.type_combo_box.setToolTip("Select what article types you want to check the helpfulness data metrics for.\nLeave as is to pull the overall metrics.")
        self.type_combo_box.setMinimumWidth(210)

        self.type_combo_box.addItems(["PD","RPD","BG"])
        self.pull_button = QtGui.QPushButton("Pull Helpfulness Data")
        self.helpfulness_report_table = QtGui.QTableWidget(0,0)
        self.helpfulness_data_table = QtGui.QTableWidget(0,0)
        style_string = """
        .QTableWidget {
            gridline-color: rgb(0, 0, 0);
        }
        """
        self.setStyleSheet(style_string)
        self.reports_tab = QtGui.QTabWidget()
        self.reports_tab.addTab(self.helpfulness_report_table,"Report")
        self.reports_tab.addTab(self.helpfulness_data_table,"Data")
        self.layout = QtGui.QVBoxLayout()
        self.form_layout = QtGui.QHBoxLayout()
        self.form_layout.addWidget(self.start_date_label,0)
        self.form_layout.addWidget(self.start_date_edit,0)
        self.form_layout.addWidget(self.end_date_label,0)
        self.form_layout.addWidget(self.end_date_edit,0)
        self.form_layout.addWidget(self.type_combo_box,2)
        self.form_layout.addWidget(self.pull_button,0)
        self.layout.addLayout(self.form_layout,0)
        self.layout.addWidget(self.reports_tab,1)
        self.setLayout(self.layout)
        self.setWindowTitle("Farm Hand")
        if "OINKModules" in os.getcwd():
            icon_file_name_path = os.path.join(os.path.join('..',"Images"),'PORK_Icon.png')
        else:
            icon_file_name_path = os.path.join('Images','PORK_Icon.png')
        self.setWindowIcon(QtGui.QIcon(icon_file_name_path))

    def mapEvents(self):
        self.start_date_edit.dateChanged.connect(self.limitEndDate)
        self.pull_button.clicked.connect(self.populateReport)

    def keyPressEvent(self, e):
        if (e.modifiers() & QtCore.Qt.ControlModifier):
            if e.key() == QtCore.Qt.Key_C:
                current_tab = self.reports_tab.currentIndex()

                if current_tab == 0:
                    table_to_copy = self.helpfulness_report_table
                else:
                    table_to_copy = self.helpfulness_data_table

                selected = table_to_copy.selectedRanges()
                s = '\t'+"\t".join([str(table_to_copy.horizontalHeaderItem(i).text()) for i in xrange(selected[0].leftColumn(), selected[0].rightColumn()+1)])
                s = s + '\n'
                for r in xrange(selected[0].topRow(), selected[0].bottomRow()+1):
                    s += str(r+1) + '\t' 
                    for c in xrange(selected[0].leftColumn(), selected[0].rightColumn()+1):
                        try:
                            s += str(table_to_copy.item(r,c).text()) + "\t"
                        except AttributeError:
                            s += "\t"
                    s = s[:-1] + "\n" #eliminate last '\t'
                self.clip.setText(s)

    def populateReport(self):
#        print "Populating report"
        entity_types = self.type_combo_box.getCheckedItems()
        if len(entity_types) == 0:
            entity_types = None
        data = MOSES.getFeedbackBetweenDates(self.user_id, self.password, self.start_date_edit.date().toPyDate(), self.end_date_edit.date().toPyDate(), entity_types)
        if data["total"] != 0: 
            self.helpfulness_report_table.setRowCount(1)
            self.helpfulness_report_table.setColumnCount(4)
            self.helpfulness_report_table.setHorizontalHeaderLabels(["Yes","No","Total","Helpfulness%"])
            self.helpfulness_report_table.setItem(0,0,QtGui.QTableWidgetItem(str(data["yes"])))
            self.helpfulness_report_table.setItem(0,1,QtGui.QTableWidgetItem(str(data["total"]-data["yes"])))
            self.helpfulness_report_table.setItem(0,2,QtGui.QTableWidgetItem(str(data["total"])))
            self.helpfulness_report_table.setItem(0,3,QtGui.QTableWidgetItem("%.2f%%"%(100*data["yes"]/data["total"])))
            #print data["data"][0].keys()
            data_headers = ["Time Stamp","Article Type","Item ID","FSN","Feedback","Feedback Comment"]
            table_rows = len(data["data"])
            self.helpfulness_data_table.setSortingEnabled(False)
            self.helpfulness_data_table.setRowCount(table_rows)
            self.helpfulness_data_table.setColumnCount(len(data_headers))
            self.helpfulness_data_table.setHorizontalHeaderLabels(data_headers)
            for row_index in range(table_rows):
                self.helpfulness_data_table.setItem(row_index,0,QtGui.QTableWidgetItem(str(data["data"][row_index]["create_stamp"])))
                self.helpfulness_data_table.setItem(row_index,1,QtGui.QTableWidgetItem(str(data["data"][row_index]["entity_type"])))
                self.helpfulness_data_table.setItem(row_index,2,QtGui.QTableWidgetItem(str(data["data"][row_index]["entity_id"])))
                self.helpfulness_data_table.setItem(row_index,3,QtGui.QTableWidgetItem(str(data["data"][row_index]["FSN"])))
                self.helpfulness_data_table.setItem(row_index,4,QtGui.QTableWidgetItem(str(data["data"][row_index]["feedback"])))
                self.helpfulness_data_table.setItem(row_index,5,QtGui.QTableWidgetItem(str(data["data"][row_index]["metadata"])))
            self.helpfulness_data_table.setSortingEnabled(True)
            self.helpfulness_data_table.resizeColumnsToContents()
            self.helpfulness_data_table.setColumnWidth(5,200)
            self.helpfulness_data_table.setWordWrap(True)
            self.helpfulness_data_table.resizeRowsToContents()
            self.alertMessage("Completed!","Finished summarizing feedback data for the selected entity types between %s and %s" %(self.start_date_edit.date().toPyDate(), self.end_date_edit.date().toPyDate()))
        else:
            self.alertMessage("No Data Available!","There is no feedback available for the selected entity types between %s and %s" %(self.start_date_edit.date().toPyDate(), self.end_date_edit.date().toPyDate()))

    def limitEndDate(self):
        self.end_date_edit.setMinimumDate(self.start_date_edit.date().toPyDate())

    def alertMessage(self, title, message):
        QtGui.QMessageBox.about(self, title, message)
Ejemplo n.º 25
0
    def createUI(self):
        self.users_list_label = QtGui.QLabel("Users: ")
        self.users_list_view = QtGui.QListWidget()

        self.add_employee_button = ImageButton(
                                        os.path.join("Images","add.png"),
                                            48,
                                            48,
                                            os.path.join("Images","add_mouseover.png")
                                        )
        self.edit_employee_button = ImageButton(
                                            os.path.join("Images","modify.png"),
                                            48,
                                            48,
                                            os.path.join("Images","modify_mouseover.png")
                                        )

        self.edit_employee_button.setCheckable(True)
        self.add_employee_button.setCheckable(True)
        self.button_group = QtGui.QButtonGroup()
        self.button_group.addButton(self.edit_employee_button)
        self.button_group.addButton(self.add_employee_button)
        self.button_group.setExclusive(True)


        user_list_buttons_layout = QtGui.QHBoxLayout()
        user_list_buttons_layout.addWidget(self.add_employee_button,0)
        user_list_buttons_layout.addWidget(self.edit_employee_button,0)

        users_list_layout = QtGui.QVBoxLayout()
        users_list_layout.addWidget(self.users_list_label,0)
        users_list_layout.addWidget(self.users_list_view,3)
        users_list_layout.addLayout(user_list_buttons_layout,1)
        users_list_layout.addStretch(1)

        self.employee_id_label = QtGui.QLabel("Employee ID")
        self.employee_id_lineedit = QtGui.QLineEdit()
        self.employee_name_label = QtGui.QLabel("Name")
        self.employee_name_lineedit = QtGui.QLineEdit()
        name_id_row = QtGui.QHBoxLayout()
        name_id_row.addWidget(self.employee_id_label,0)
        name_id_row.addWidget(self.employee_id_lineedit,2)
        name_id_row.addWidget(self.employee_name_label,0)
        name_id_row.addWidget(self.employee_name_lineedit,2)

        self.email_label = QtGui.QLabel("Email ID:")
        self.email_lineedit = QtGui.QLineEdit()
        email_row = QtGui.QHBoxLayout()
        email_row.addWidget(self.email_label,0)
        email_row.addWidget(self.email_lineedit,2)

        self.current_role_label = QtGui.QLabel("Role:")
        self.current_role_combobox = QtGui.QComboBox()
        current_role_row = QtGui.QHBoxLayout()
        current_role_row.addWidget(self.current_role_label,0)
        current_role_row.addWidget(self.current_role_combobox,1)

        self.doj_label = QtGui.QLabel("Date of Joining:")
        self.doj_dateedit = FormattedDateEdit()
        self.dol_checkbox = QtGui.QCheckBox("Last Working Date:")
        self.dol_checkbox.setToolTip("Check to mark the LWD of this employee.\nLeave unchecked if the employee is still in the team.")
        self.dol_dateedit = FormattedDateEdit()
        self.doj_dateedit.setCalendarPopup(True)
        self.dol_dateedit.setCalendarPopup(True)

        doj_dol_row = QtGui.QHBoxLayout()
        doj_dol_row.addWidget(self.doj_label, 0)
        doj_dol_row.addWidget(self.doj_dateedit, 0)
        doj_dol_row.addWidget(self.dol_checkbox, 0)
        doj_dol_row.addWidget(self.dol_dateedit, 0)

        self.former_role_label = QtGui.QLabel("Former Role:")
        self.former_role_combobox = QtGui.QComboBox()
        self.dop_checkbox = QtGui.QCheckBox("Promoted")
        self.dop_checkbox.setToolTip("Check this to record a promotion and keep details of the former role.")
        self.dop_label = QtGui.QLabel("Date of Promotion:")
        self.dop_dateedit = FormattedDateEdit()
        self.dop_dateedit.setCalendarPopup(True)

        promotion_row = QtGui.QHBoxLayout()
        promotion_row.addWidget(self.dop_checkbox, 0)
        promotion_row.addWidget(self.dop_label, 0)
        promotion_row.addWidget(self.dop_dateedit, 1)
        promotion_row.addWidget(self.former_role_label, 0)
        promotion_row.addWidget(self.former_role_combobox, 1)

        self.access_label = QtGui.QLabel("OINK Application Access")
        self.access_combobox = CheckableComboBox("Applications")
        self.access_combobox.addItems(["PORK","BACON","VINDALOO"])
        access_row = QtGui.QHBoxLayout()
        access_row.addWidget(self.access_label,0)
        access_row.addWidget(self.access_combobox,2)
        access_row.addStretch(1)

        self.reset_password_button = QtGui.QPushButton("Reset Password")
        self.save_button = QtGui.QPushButton("Save")
        self.reset_button = QtGui.QPushButton("Revert")

        form_buttons_layout = QtGui.QHBoxLayout()
        form_buttons_layout.addStretch(2)
        form_buttons_layout.addWidget(self.reset_password_button,0)
        form_buttons_layout.addWidget(self.save_button,0)
        form_buttons_layout.addWidget(self.reset_button,0)

        self.progress_bar = ProgressBar()
        self.status_label = QtGui.QLabel()

        self.manager_mapping = CopiableQTableWidget(0,0)

        self.manager_name_label = QtGui.QLabel("Reporting Manager:")
        self.manager_name_combobox = QtGui.QComboBox()
        self.manager_effective_date_label = QtGui.QLabel("Revision Date:")
        self.manager_effective_dateedit = FormattedDateEdit()
        self.manager_effective_dateedit.setDate(datetime.date.today())
        self.manager_effective_dateedit.setCalendarPopup(True)
        self.add_new_manager_mapping_row = QtGui.QPushButton("Add or Update")
        self.remove_manager_mapping_row = QtGui.QPushButton("Remove")

        manager_mapping_form = QtGui.QHBoxLayout()
        manager_mapping_form.addWidget(self.manager_name_label,0)
        manager_mapping_form.addWidget(self.manager_name_combobox,2)
        manager_mapping_form.addWidget(self.manager_effective_date_label,0)
        manager_mapping_form.addWidget(self.manager_effective_dateedit,1)
        manager_mapping_form.addWidget(self.add_new_manager_mapping_row,0)
        manager_mapping_form.addWidget(self.remove_manager_mapping_row,0)

        user_data_form_layout = QtGui.QVBoxLayout()
        user_data_form_layout.addLayout(name_id_row,0)
        user_data_form_layout.addLayout(email_row,0)
        user_data_form_layout.addLayout(current_role_row,0)
        user_data_form_layout.addLayout(doj_dol_row,0)
        user_data_form_layout.addLayout(promotion_row,0)
        user_data_form_layout.addLayout(access_row,0)
        user_data_form_layout.addLayout(form_buttons_layout,0)
        user_data_form_layout.addWidget(self.manager_mapping,1)
        user_data_form_layout.addLayout(manager_mapping_form,0)
        user_data_form_layout.addStretch(1)
        user_data_form_layout.addWidget(self.progress_bar,0)
        user_data_form_layout.addWidget(self.status_label,0)

        user_data_form = QtGui.QGroupBox("User Information:")
        user_data_form.setLayout(user_data_form_layout)

        layout = QtGui.QHBoxLayout()
        layout.addLayout(users_list_layout,1)
        layout.addWidget(user_data_form,2)
        self.central_widget = QtGui.QWidget()
        self.central_widget.setLayout(layout)

        self.setCentralWidget(self.central_widget)
        self.setWindowTitle("OINK User Manager")
        self.setWindowIcon(QtGui.QIcon(os.path.join('Images','PORK_Icon.png')))
        self.show()
Ejemplo n.º 26
0
    def createUI(self):
        self.date_label = QtGui.QLabel("Date(s):")
        self.start_date = FormattedDateEdit()
        self.end_date = FormattedDateEdit()

        self.employees_label = QtGui.QLabel("Employees:")
        self.employees_selection_box = CheckableComboBox("Employees")
        self.all_button = QtGui.QPushButton("Select All")
        self.clear_button = QtGui.QPushButton("Clear")

        self.refresh_table_button = QtGui.QPushButton("Refresh Table")
        self.approve_selected_button = QtGui.QPushButton("Approved")
        self.approve_selected_button.setCheckable(True)
        self.reject_selected_button = QtGui.QPushButton("Rejected")
        self.reject_selected_button.setCheckable(True)
        self.pending_selected_button = QtGui.QPushButton("Pending")
        self.pending_selected_button.setCheckable(True)

        self.button_group = QtGui.QButtonGroup()
        self.button_group.addButton(self.approve_selected_button)
        self.button_group.addButton(self.reject_selected_button)
        self.button_group.addButton(self.pending_selected_button)
        self.button_group.setExclusive(True)

        self.approval_comment_label = QtGui.QLabel(
            "Approval\\Rejection Comment:")
        self.rejection_comment_lineedit = QtGui.QLineEdit()

        self.leave_table = CopiableQTableWidget(0, 0)

        self.status_label = QtGui.QLabel("Status")
        self.status_combobox = QtGui.QComboBox()
        self.status_combobox.addItems(["Working", "Leave"])
        self.comment_label = QtGui.QLabel("Comment")
        self.comment_lineedit = QtGui.QLineEdit()
        self.save_selected_button = QtGui.QPushButton("Save")
        self.save_selected_button.setEnabled(False)
        self.save_all_button = QtGui.QPushButton("Save All")

        row_1 = QtGui.QHBoxLayout()
        row_1.addWidget(self.date_label, 0)
        row_1.addWidget(self.start_date, 0)
        row_1.addWidget(self.end_date, 0)
        row_1.addWidget(self.employees_label, 0)
        row_1.addWidget(self.employees_selection_box, 0)
        row_1.addWidget(self.all_button, 0)
        row_1.addWidget(self.clear_button, 0)

        self.relaxation_label = QtGui.QLabel("Relaxation")
        self.relaxation_spinbox = QtGui.QDoubleSpinBox()
        self.relaxation_spinbox.setSuffix("%")

        row_2 = QtGui.QHBoxLayout()
        row_2.addWidget(self.status_label, 0)
        row_2.addWidget(self.status_combobox, 0)
        row_2.addWidget(self.relaxation_label, 0)
        row_2.addWidget(self.relaxation_spinbox, 0)
        row_2.addWidget(self.comment_label, 0)
        row_2.addWidget(self.comment_lineedit, 0)

        row_3 = QtGui.QHBoxLayout()
        row_3.addWidget(self.approval_comment_label, 0)
        row_3.addWidget(self.rejection_comment_lineedit, 0)
        row_3.addWidget(self.approve_selected_button, 0)
        row_3.addWidget(self.reject_selected_button, 0)
        row_3.addWidget(self.pending_selected_button, 0)
        row_3.addWidget(self.save_selected_button, 0)
        row_3.addWidget(self.save_all_button, 0)
        row_3.addWidget(self.refresh_table_button, 0)

        layout = QtGui.QVBoxLayout()
        layout.addLayout(row_1)
        layout.addLayout(row_2)
        layout.addLayout(row_3)
        layout.addWidget(self.leave_table)

        self.setLayout(layout)
        self.setWindowTitle("Leaves Manager")
        self.setWindowIcon(
            QtGui.QIcon(os.path.join(MOSES.getPathToImages(),
                                     "PORK_Icon.png")))
        self.show()