예제 #1
0
파일: products.py 프로젝트: umax/diabetto
    def remove_cb(self, widget):
        """Removes category or product."""

        model, iterator = self.treeview.get_selection().get_selected()
        if self.mode == CATEGORIES_MODE:
            try:
                cid = model[iterator][1]
            except:  # no category is selected
                return
            else:
                if show_question_dialog(
                    self.window, _("Category removing"), _("Do you want to remove selected category?")
                ):
                    self.controller.remove_category(cid)
                    self._show_categories()
        else:
            try:
                pid = model[iterator][3]
            except:  # no product is selected
                return
            else:
                if show_question_dialog(
                    self.window, _("Product removing"), _("Do you want to remove selected product?")
                ):
                    self.controller.remove_product(pid)
                    self._show_products(self.cid)
예제 #2
0
    def remove_cb(self, widget):
        """Removes composition or product."""

        model, iterator = self.treeview.get_selection().get_selected()
        if self.mode == COMPOSITIONS_MODE:
            try:
                compid = model[iterator][4]
            except: # no composition is selected
                return
            else:
                if show_question_dialog(self.window, \
                    _('Composition removing'), \
                    _('Do you want to remove selected composition?')):
                    self.controller.remove_composition(compid)
                    self._show_compositions()
        else:
            try:
                pid = model[iterator][2]
            except: # no product is selected
                return
            else:
                if show_question_dialog(self.window, _('Product removing'), \
                    _('Do you want to remove selected product from composition?')):
                    self.controller.remove_product_from_composition( \
                        self.compid, pid)
                    self._show_products_in_composition()