Ejemplo n.º 1
0
 def settings_url(self):
     user = getSecurityManager().getUser()
     if IMembraneUser.providedBy(user):
         mt = getToolByName(self.context, "membrane_tool")
         home = mt.getUserObject(user_id=user.getUserId())
         return "%s/@@edit" % home.absolute_url()
     else:
         home = getPortal(self.context)
         return "%s/@@settings" % home.absolute_url()
Ejemplo n.º 2
0
 def settings_url(self):
     user = getSecurityManager().getUser()
     if IMembraneUser.providedBy(user):
         mt = getToolByName(self.context, "membrane_tool")
         home = mt.getUserObject(user_id=user.getUserId())
         return "%s/@@edit" % home.absolute_url()
     else:
         home = getPortal(self.context)
         return "%s/@@settings" % home.absolute_url()
Ejemplo n.º 3
0
 def __call__(self):
     user = getSecurityManager().getUser()
     if IMembraneUser.providedBy(user):
         mt = getToolByName(self.context, "membrane_tool")
         obj = mt.getUserObject(user_id=user.getUserId())
         if ICountryManager.providedBy(obj):
             return self.request.response.redirect(aq_parent(obj).absolute_url())
         return self.request.response.redirect(obj.absolute_url())
     portal = aq_inner(self.context)
     return self.request.response.redirect("%s/sectors/" % portal.absolute_url())
Ejemplo n.º 4
0
 def render(self):
     user = getSecurityManager().getUser()
     if IMembraneUser.providedBy(user):
         mt = getToolByName(self.context, "membrane_tool")
         obj = mt.getUserObject(user_id=user.getUserId())
         if ICountryManager.providedBy(obj):
             self.request.response.redirect(aq_parent(obj).absolute_url())
         else:
             self.request.response.redirect(obj.absolute_url())
     else:
         portal = aq_inner(self.context)
         self.request.response.redirect(
                 "%s/sectors/" % portal.absolute_url())
Ejemplo n.º 5
0
    def update(self):
        context = aq_inner(self.context)
        portal = getPortal(context)
        currentUrl = self.request.getURL()[len(portal.absolute_url()):]
        user = getSecurityManager().getUser()

        if IMembraneUser.providedBy(user):
            mt = getToolByName(self.context, "membrane_tool")
            user_object = mt.getUserObject(user_id=user.getUserId())
        else:
            user_object = None

        for (test, id) in self.current_map:
            if test.match(currentUrl):
                current = id
                break
        else:
            current = None

        results = [{
            "id": "sectors",
            "title": _("nav_surveys", default=u"OiRA Tools"),
            "url": portal.sectors.absolute_url(),
            "class": "current" if current == "sectors" else None
        }]

        if checkPermission(portal, "Manage portal"):
            for country in aq_chain(context):
                if ICountry.providedBy(country):
                    url = "%s/@@manage-users" % country.absolute_url()
                    break
            else:
                countries = sorted(portal.sectors.keys())
                url = "%s/@@manage-users" % \
                        portal.sectors[countries[0]].absolute_url()
            results.append({
                "id":
                "usermgmt",
                "title":
                _("nav_usermanagement", default=u"User management"),
                "url":
                url,
                "class":
                "current" if current == "usermgmt" else None
            })
            results.append({
                "id":
                "documents",
                "title":
                _("nav_documents", default=u"Documents"),
                "url":
                portal.documents.absolute_url(),
                "class":
                "current" if current == "documents" else None
            })
        elif ICountryManager.providedBy(user_object):
            country = aq_parent(user_object)
            results.append({
                "id":
                "usermgmt",
                "title":
                _("nav_usermanagement", default=u"User management"),
                "url":
                "%s/@@manage-users" % country.absolute_url(),
                "class":
                "current" if current == "usermgmt" else None
            })

        if user_object is not None:
            country = aq_parent(user_object)
            results.append({
                "id": "help",
                "title": _("nav_help", default=u"Help"),
                "url": "%s/help" % country.absolute_url(),
                "class": "current" if current == "help" else None
            })

        self.tabs = results
        self.home_url = portal.absolute_url()
Ejemplo n.º 6
0
    def update(self):
        context = aq_inner(self.context)
        portal = getPortal(context)
        currentUrl = self.request.getURL()[len(portal.absolute_url()):]
        user = getSecurityManager().getUser()

        if IMembraneUser.providedBy(user):
            mt = getToolByName(self.context, "membrane_tool")
            user_object = mt.getUserObject(user_id=user.getUserId())
        else:
            user_object = None

        for (test, id) in self.current_map:
            if test.match(currentUrl):
                current = id
                break
        else:
            current = None

        results = [{"id": "sectors",
                    "title": _("nav_surveys", default=u"OiRA Tools"),
                    "url": portal.sectors.absolute_url(),
                    "class": "current" if current == "sectors" else None}]

        if checkPermission(portal, "Manage portal"):
            for country in aq_chain(context):
                if ICountry.providedBy(country):
                    url = "%s/@@manage-users" % country.absolute_url()
                    break
            else:
                countries = sorted(portal.sectors.keys())
                url = "%s/@@manage-users" % \
                        portal.sectors[countries[0]].absolute_url()
            results.append({"id": "usermgmt",
                            "title": _("nav_usermanagement",
                                        default=u"User management"),
                            "url": url,
                            "class": "current" if current == "usermgmt"
                                                else None})
            results.append({"id": "documents",
                            "title": _("nav_documents", default=u"Documents"),
                            "url": portal.documents.absolute_url(),
                            "class": "current" if current == "documents"
                                                else None})
        elif ICountryManager.providedBy(user_object):
            country = aq_parent(user_object)
            results.append({"id": "usermgmt",
                            "title": _("nav_usermanagement",
                                        default=u"User management"),
                            "url": "%s/@@manage-users" %
                                        country.absolute_url(),
                            "class": "current" if current == "usermgmt"
                                                else None})

        if user_object is not None:
            country = aq_parent(user_object)
            results.append({"id": "help",
                            "title": _("nav_help", default=u"Help"),
                            "url": "%s/help" % country.absolute_url(),
                            "class": "current" if current == "help"
                                                else None})

        self.tabs = results
        self.home_url = portal.absolute_url()