示例#1
0
                                   secure=True,
                                   modifies=True,
                                   successHandler=self.onMkDir)
        r.dirName = dirName

    def onMkDir(self, req):
        dirName = req.dirName
        conf["mainWindow"].log(
            "success", translate("Directory \"{name}\" created.",
                                 name=dirName))

    def resetLoadingState(self):
        pass


actionDelegateSelector.insert(3, AddNodeAction.isSuitableFor, AddNodeAction)


class EditAction(html5.ext.Button):
    """
		Provides editing in a tree.simple application.
		If a directory is selected, it opens a dialog for renaming that directory,
		otherwise the full editWidget is used.
	"""
    def __init__(self, *args, **kwargs):
        super(EditAction, self).__init__(translate("Edit"), *args, **kwargs)
        self["class"] = "icon edit"
        self["disabled"] = True
        self.isDisabled = True

    def onAttach(self):
示例#2
0
                        "modul_%s" % self.parent().parent().module,
                        "apptype_hierarchy", "action_add"
                    ])
        conf["mainWindow"].stackPane(pane)
        edwg = EditWidget(self.parent().parent().module,
                          EditWidget.appHierarchy,
                          node=self.parent().parent().rootNode,
                          context=self.parent().parent().context)
        pane.addWidget(edwg)
        pane.focus()

    def resetLoadingState(self):
        pass


actionDelegateSelector.insert(1, AddAction.isSuitableFor, AddAction)


class EditAction(html5.ext.Button):
    """
		Edits a node in a hierarchy application.
	"""
    def __init__(self, *args, **kwargs):
        super(EditAction, self).__init__(translate("Edit"), *args, **kwargs)
        self["class"] = "icon edit"
        self["disabled"] = True
        self.isDisabled = True

    def onAttach(self):
        super(EditAction, self).onAttach()
        self.parent().parent().selectionChangedEvent.register(self)
示例#3
0
            "modules"][module].keys() and conf["modules"][module][
                "disabledFunctions"] and "add-leaf" in conf["modules"][module][
                    "disabledFunctions"]

        return correctAction and correctHandler and hasAccess and not isDisabled

    def onClick(self, sender=None):
        uploader = FileSelectUploader()
        self.parent().parent().appendChild(uploader)
        uploader.element.click()

    def resetLoadingState(self):
        pass


actionDelegateSelector.insert(3, AddLeafAction.isSuitableFor, AddLeafAction)


class DownloadAction(html5.ext.Button):
    """
		Allows downloading files from the server.
	"""
    def __init__(self, *args, **kwargs):
        super(DownloadAction, self).__init__(translate("Download"), *args,
                                             **kwargs)
        self["class"] = "icon download"
        self["disabled"] = True
        self.isDisabled = True

    def onAttach(self):
        super(DownloadAction, self).onAttach()
示例#4
0
        self.disable()
        req = NetworkService.request(
            self.parent().parent().module,
            "triggerSendNewsletter", {"key": selection[0]["key"]},
            secure=True,
            successHandler=self.onSendNewsletterSuccess,
            failureHandler=self.onSendNewsletterFailure)
        req.selection = selection[0]

    def onSendNewsletterSuccess(self, req):
        conf["mainWindow"].log(
            "success",
            translate(u"Versand von '{name}' erfolgreich gestartet!",
                      name=req.selection["name"]))

    def onSendNewsletterFailure(self, req, code):
        if int(code) in [403, 401]:
            conf["mainWindow"].log(
                "error",
                translate(
                    u"Sie verfügen nicht über das Recht, diese Funktion auszführen."
                ))
        else:
            conf["mainWindow"].log("error",
                                   translate(u"Fehler {code}", code=str(code)))


actionDelegateSelector.insert(5, SendNewsletterAction.isSuitableFor,
                              SendNewsletterAction)
示例#5
0
                        iconClasses=[
                            "modul_%s" % self.parent().parent().module,
                            "apptype_list", "action_add"
                        ])
        conf["mainWindow"].stackPane(pane)
        edwg = EditWidget(self.parent().parent().module,
                          EditWidget.appList,
                          context=self.parent().parent().context)
        pane.addWidget(edwg)
        pane.focus()

    def resetLoadingState(self):
        pass


actionDelegateSelector.insert(1, AddAction.isSuitableFor, AddAction)


class EditAction(html5.ext.Button):
    """
		Allows editing an entry in a list-module.
	"""
    def __init__(self, *args, **kwargs):
        super(EditAction, self).__init__(translate("Edit"), *args, **kwargs)
        self["class"] = "icon edit"
        self["disabled"] = True
        self.isDisabled = True

    def onAttach(self):
        super(EditAction, self).onAttach()
        self.parent().parent().selectionChangedEvent.register(self)
示例#6
0
            or module + "-add" in conf["currentUser"]["access"])
        isDisabled = module is not None and "disabledFunctions" in conf["modules"][module].keys() and \
                     conf["modules"][module]["disabledFunctions"] and "add-leaf" in conf["modules"][module][
                      "disabledFunctions"]

        return correctAction and correctHandler and hasAccess and not isDisabled

    def onClick(self, sender=None):
        pane = Pane("Add",
                    closeable=True,
                    iconClasses=[
                        "module_%s" % self.parent().parent().module,
                        "apptype_tree", "action_add_leaf"
                    ])
        conf["mainWindow"].stackPane(pane)
        edwg = EditWidget(self.parent().parent().module,
                          EditWidget.appTree,
                          node=self.parent().parent().node,
                          skelType="leaf",
                          context={"kind": "link"})

        pane.addWidget(edwg)
        pane.focus()

    def resetLoadingState(self):
        pass


actionDelegateSelector.insert(10, AddFileOrLinkAction.isSuitableFor,
                              AddFileOrLinkAction)
示例#7
0
class ShopMarkPayedAction(ShopMarkAction):
    def __init__(self, *args, **kwargs):
        super(ShopMarkPayedAction, self).__init__(
            "markPayed",
            "Mark payed",
            cls="order_markpayed",
            txtQuestion="Do you really want to mark {count} orders as payed?",
            txtSuccess="{count} orders had been successfully set as payed.",
            txtFailure="Failed to mark order payed")

    @staticmethod
    def isSuitableFor(module, handler, actionName):
        return actionName == "markpayed" and handler == "list.order"


actionDelegateSelector.insert(1, ShopMarkPayedAction.isSuitableFor,
                              ShopMarkPayedAction)

# ShopMarkSentAction ---------------------------------------------------------------------------------------------------


class ShopMarkSentAction(ShopMarkAction):
    def __init__(self, *args, **kwargs):
        super(ShopMarkSentAction, self).__init__(
            "markSend",
            "Mark sent",
            cls="order_marksent",
            txtQuestion="Do you really want to mark {count} orders as sent?",
            txtSuccess="{count} orders had been successfully set as sent.",
            txtFailure="Failed to mark order sent")

    @staticmethod
示例#8
0
        if widget:
            pane = Pane(translate(u"{module} - {name}",
                                  module=self.title,
                                  name=title),
                        closeable=True,
                        iconURL=self.icon,
                        iconClasses=["module_%s" % self.contextModule])
            conf["mainWindow"].stackPane(pane)

            pane.addWidget(widget)
            pane.focus()
        else:
            print("Widget could not be generated")

    @staticmethod
    def isSuitableFor(module, handler, actionName):
        if module is None or module not in conf["modules"].keys():
            return False

        if not actionName.startswith("context."):
            return False

        mod = actionName.split(".", 3)[1]
        cuser = conf["currentUser"]
        return "root" in cuser["access"] or ("%s-view" %
                                             mod) in cuser["access"]


actionDelegateSelector.insert(1, ContextAction.isSuitableFor, ContextAction)
示例#9
0
		hasAccess = conf["currentUser"] and ("root" in conf["currentUser"]["access"] or module+"-add" in conf["currentUser"]["access"])
		isDisabled = module is not None and "disabledFunctions" in conf["modules"][module].keys() and conf["modules"][module]["disabledFunctions"] and "add-leaf" in conf["modules"][module]["disabledFunctions"]

		return correctAction and correctHandler and hasAccess and not isDisabled

	def onClick(self, sender=None):
		pane = Pane("Add", closeable=True)
		conf["mainWindow"].stackPane( pane, iconClasses=["modul_%s" % self.parent().parent().module, "apptype_tree", "action_add_leaf" ] )
		edwg = EditWidget( self.parent().parent().module, EditWidget.appTree, node=self.parent().parent().node, skelType="leaf" )
		pane.addWidget( edwg )
		pane.focus()

	def resetLoadingState(self):
		pass

actionDelegateSelector.insert( 1, AddLeafAction.isSuitableFor, AddLeafAction )


class AddNodeAction( html5.ext.Button ):
	"""
		Creates a new node (ie. a directory) for a tree application
	"""
	def __init__(self, *args, **kwargs):
		super( AddNodeAction, self ).__init__(  translate("Add"), *args, **kwargs )
		self["class"] = "icon add node"

	@staticmethod
	def isSuitableFor( module, handler, actionName ):
		if module is None or module not in conf["modules"].keys():
			return False
示例#10
0
文件: edit.py 项目: phorward/viur-vi
		super( SaveContinue, self ).__init__( translate("Save-Continue"), *args, **kwargs )
		self["class"] = "icon save continue"

	@staticmethod
	def isSuitableFor( module, handler, actionName ):
		return( actionName=="save.continue" )

	def onClick(self, sender=None):
		self["class"].append("is_loading")
		self.parent().parent().doSave(closeOnSuccess=False)

	def resetLoadingState(self):
		if "is_loading" in self["class"]:
			self["class"].remove("is_loading")

actionDelegateSelector.insert( 1, SaveContinue.isSuitableFor, SaveContinue )

class SaveSingleton(html5.ext.Button):
	def __init__(self, *args, **kwargs):
		super(SaveSingleton, self).__init__(translate("Save"), *args, **kwargs)
		self["class"] = "icon save close"

	@staticmethod
	def isSuitableFor(module, handler, actionName):
		return actionName == "save.singleton" and module != "_tasks"

	def onClick(self, sender=None):
		self["class"].append("is_loading")
		self.parent().parent().doSave(closeOnSuccess=False)

	def resetLoadingState(self):
示例#11
0
        if not selection:
            return

        for s in selection:
            r = NetworkService.request("user",
                                       "resetPassword",
                                       params={"key": s["key"]},
                                       successHandler=self.onUserResetSuccess,
                                       failureHandler=self.onUserResetFailure)
            r.dataset = s

    def onUserResetSuccess(self, req):
        conf["mainWindow"].log(
            "success", translate("User '%s' was reset!" % req.dataset["name"]))

    def onUserResetFailure(self, *args, **kwargs):
        print("Failed to reset")

        if "code" in kwargs.keys():
            print("Error code: %s" % kwargs["code"])
        else:
            print("Additional info: %s" % kwargs)

        conf["mainWindow"].log("failure", translate("Unable to reset user!"))


actionDelegateSelector.insert(1, ResetPasswordAction.isSuitableFor,
                              ResetPasswordAction)

print("--- resetpasswordPlugin is up and running ---")
示例#12
0
文件: wysiwyg.py 项目: Xeon2003/vi
    def resetLoadingState(self):
        pass


class TextStyleBold(BasicTextAction):
    cmd = "bold"
    isActiveTag = "B"
    title = translate("Bold")

    #def onClick(self, sender = None):
    #	self.parent().parent().editor.toggleSelection("strong")


actionDelegateSelector.insert(
    1, lambda modul, handler, actionName: actionName == "style.text.bold",
    TextStyleBold)


class TextStyleItalic(BasicTextAction):
    cmd = "italic"
    isActiveTag = "I"
    title = translate("Italic")

    #def onClick(self, sender=None):
    #	self.parent().parent().editor.toggleSelection("em")


actionDelegateSelector.insert(
    1, lambda modul, handler, actionName: actionName == "style.text.italic",
    TextStyleItalic)