コード例 #1
0
    def getPermissions(self, response):
        permissions = LomBase.getPermissions(self, response)

        permissions.replace_value("public", False)
        permissions.add_value("autoCreateGroups", True)
        permissions.add_value("groups", ["public"])

        return permissions
コード例 #2
0
    def getPermissions(self, response):
        """
        In case license information, in the form of counties (Kreis codes), is available. This changes the permissions from
        public to private and sets accordingly the groups and mediacenters. For more information regarding the available
        Merlin county (kreis) codes please consult 'http://merlin.nibis.de/index.php?action=kreise'
        """

        permissions = LomBase.getPermissions(self, response)

        element_dict = response.meta["item"]

        permissions.replace_value("public", False)
        permissions.add_value("autoCreateGroups", True)

        groups = []

        county_ids = element_dict["county_ids"]
        public_county = "county-3100"

        # If there is only one element and is the County code 3100, then it is public content.
        if len(county_ids) == 1 and str(county_ids[0]) == public_county:
            # Add to state-wide public group.
            # groups.append("state-LowerSaxony-public")
            groups.append("LowerSaxony-public")

            # Add 1 group per County-code, which in this case is just "100" (3100).
            groups.extend(county_ids)
        else:
            # Add to state-wide private/licensed group.
            # groups.append("state-LowerSaxony-licensed")
            groups.append("LowerSaxony-private")

            # If County code 100 (country-wide) is included in the list, remove it.
            if public_county in county_ids:
                county_ids.remove(public_county)

            # Add 1 group per county.
            groups.extend(county_ids)

        permissions.add_value("groups", groups)

        return permissions
コード例 #3
0
    def getPermissions(self, response):
        """
        Licensing information is controlled via the 'oeffentlich' flag. When it is '1' it is available to the public,
        otherwise only to Thuringia. Therefore, when the latter happens we set the public to private, and set the groups
        and mediacenters accordingly.
        """
        permissions = LomBase.getPermissions(self, response)

        # Self-explained. Only 1 media center in this case.
        permissions.add_value("autoCreateGroups", True)
        # permissions.add_value("autoCreateMediacenters", True)

        element_dict = response.meta["item"]
        permissions.replace_value('public', False)
        if "oeffentlich" in element_dict and element_dict[
                "oeffentlich"] == "0":  # private
            permissions.add_value('groups', ['Thuringia-private'])
            # permissions.add_value('mediacenters', [self.name])  # only 1 mediacenter.
        else:
            permissions.add_value('groups', ['Thuringia-public'])

        return permissions