Exemplo n.º 1
0
    def set_album_permission(self, owner_userid, album_id, perm_type, flag,
                             groups):
        """
		Sets the flag and groups for a specific perm type (view, tag, etc)

		@param owner_userid: User who owns the album
		@type owner_userid: Int

		@param album_id: ID of the album
		@type album_id: String

		@param perm_type: Permission being set
		@type perm_type: String

		@param flag: Permission value
		@type flag: Integer

		@param groups: (optional) groups to be added if flag = 2
		@type groups: List
		"""
        owner_userid = validation.cast_integer(owner_userid, "owner_userid")
        album_id = validation.cast_integer(album_id, 'album_id')
        validation.oneof(perm_type, ('view', 'comment'), 'perm_type')
        flag = validation.cast_integer(flag, 'flag')
        group_list = []
        group_val = "{}"
        if groups:
            for g in groups:
                validation.integer(g, 'group_id')
                group_list.append(validation.string(g))
            group_val = "{%s}" % ', '.join(group_list)

        d = self.app.db.query(
            """
			SELECT zoto_update_album_permission(
				%s,
				%s, %s, %s, %s)
			""", (owner_userid, album_id, perm_type, flag, group_val))
        d.addCallback(lambda _: (0, "success"))
        d.addErrback(lambda _: (-1, _.getErrorMessage()))
        return d
Exemplo n.º 2
0
	def set_album_permission(self, owner_userid, album_id, perm_type, flag, groups):
		"""
		Sets the flag and groups for a specific perm type (view, tag, etc)

		@param owner_userid: User who owns the album
		@type owner_userid: Int

		@param album_id: ID of the album
		@type album_id: String

		@param perm_type: Permission being set
		@type perm_type: String

		@param flag: Permission value
		@type flag: Integer

		@param groups: (optional) groups to be added if flag = 2
		@type groups: List
		"""
		owner_userid = validation.cast_integer(owner_userid, "owner_userid")
		album_id = validation.cast_integer(album_id, 'album_id')
		validation.oneof(perm_type, ('view', 'comment'), 'perm_type')
		flag = validation.cast_integer(flag, 'flag')
		group_list = []
		group_val = "{}"
		if groups:
			for g in groups:
				validation.integer(g, 'group_id')
				group_list.append(validation.string(g))
			group_val = "{%s}" % ', '.join(group_list)

		d = self.app.db.query("""
			SELECT zoto_update_album_permission(
				%s,
				%s, %s, %s, %s)
			""", (owner_userid, album_id, perm_type, flag, group_val))
		d.addCallback(lambda _: (0, "success"))
		d.addErrback(lambda _: (-1, _.getErrorMessage()))
		return d
Exemplo n.º 3
0
	def delete_set(self, owner_userid, set_id):
		"""
		Deletes a set.

		@param owner_username: Set owner
		@type owner_username: String

		@param set_id: ID of the set to delete
		@type set_id: Integer
		"""
		try:
			owner_userid = validation.cast_integer(owner_userid, 'owner_userid')
			set_id = validation.integer(set_id, 'set_id')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)
Exemplo n.º 4
0
    def delete_set(self, owner_userid, set_id):
        """
		Deletes a set.

		@param owner_username: Set owner
		@type owner_username: String

		@param set_id: ID of the set to delete
		@type set_id: Integer
		"""
        try:
            owner_userid = validation.cast_integer(owner_userid,
                                                   'owner_userid')
            set_id = validation.integer(set_id, 'set_id')
        except errors.ValidationError, ex:
            return utils.return_deferred_error(ex.value)
Exemplo n.º 5
0
		@param groups: If flag is 2 (private - some contacts), then this is the list of group ids applied.
		@type groups: List or None
		"""
        try:
            userid = validation.cast_integer(userid, 'userid')
            perm_type = validation.string(perm_type)
            flag = validation.cast_integer(flag, 'flag')
            validation.sequence(groups, 'groups')
        except errors.ValidationError, ex:
            return utils.return_deferred_error(ex.value)

        group_list = []
        if groups:
            for g in groups:
                validation.integer(g, 'group_id')
                group_list.append(validation.string(g))
            group_val = "{%s}" % ', '.join(group_list)
            d = self.app.api.contacts.get_contact_groups(
                userid, 0, 0, "group_id-asc")
        else:
            group_val = None
            d = Deferred()
            d.callback([])

        @stack
        def process_groups(result):
            if not result:
                if group_val:
                    raise errors.AZTKError, "userid %s doesn't have any groups, but groups were specified" % userid
            else:
Exemplo n.º 6
0
		@param groups: If flag is 2 (private - some contacts), then this is the list of group ids applied.
		@type groups: List or None
		"""
		try:
			userid = validation.cast_integer(userid, 'userid')
			perm_type = validation.string(perm_type)
			flag = validation.cast_integer(flag, 'flag')
			validation.sequence(groups, 'groups')
		except errors.ValidationError, ex:
			return utils.return_deferred_error(ex.value)

		group_list = []
		if groups:
			for g in groups:
				validation.integer(g, 'group_id')
				group_list.append(validation.string(g))
			group_val = "{%s}" % ', '.join(group_list)
			d = self.app.api.contacts.get_contact_groups(userid, 0, 0, "group_id-asc")
		else:
			group_val = None
			d = Deferred()
			d.callback([])

		@stack
		def process_groups(result):
			if not result:
				if group_val:
					raise errors.AZTKError, "userid %s doesn't have any groups, but groups were specified" % userid
			else:
				user_groups = []