示例#1
0
文件: listobj.py 项目: ilg/LambdaMLM
 def user_set_member_flag_value(self, from_user, target_user, flag_name, value):
     from_address = address_from_user(from_user)
     target_address = address_from_user(target_user)
     self.address_will_modify_address(from_address, target_address)
     member = self.member_with_address(target_address)
     if not member:
         raise NotSubscribed
     try:
         flag = MemberFlag[flag_name]
     except KeyError:
         raise UnknownFlag
     # The superAdmin flag cannot be modified by email command.
     if flag == MemberFlag.superAdmin:
         raise InsufficientPermissions
     if (
         flag not in MemberFlag.userlevel_flags()
         and MemberFlag.admin not in self.member_with_address(from_address).flags
     ):
         raise InsufficientPermissions
     if value:
         member.flags.add(flag)
     else:
         try:
             member.flags.remove(flag)
         except KeyError:
             # Trying to remove an element from the set that isn't in the set raises KeyError.  Ignore it.
             pass
     self._save()
示例#2
0
文件: listobj.py 项目: pb30/LambdaMLM
 def user_set_member_flag_value(self, from_user, target_user, flag_name,
                                value):
     from_address = address_from_user(from_user)
     target_address = address_from_user(target_user)
     self.address_will_modify_address(from_address, target_address)
     member = self.member_with_address(target_address)
     if not member:
         raise NotSubscribed
     try:
         flag = MemberFlag[flag_name]
     except KeyError:
         raise UnknownFlag
     # The superAdmin flag cannot be modified by email command.
     if flag == MemberFlag.superAdmin:
         raise InsufficientPermissions
     if flag not in MemberFlag.userlevel_flags(
     ) and MemberFlag.admin not in self.member_with_address(
             from_address).flags:
         raise InsufficientPermissions
     if value:
         member.flags.add(flag)
     else:
         try:
             member.flags.remove(flag)
         except KeyError:
             # Trying to remove an element from the set that isn't in the set raises KeyError.  Ignore it.
             pass
     self._save()
示例#3
0
文件: listobj.py 项目: ilg/LambdaMLM
 def user_own_flags(self, user):
     address = address_from_user(user)
     member = self.member_with_address(address)
     if not member:
         raise NotSubscribed
     if MemberFlag.admin in member.flags:
         all_flags = MemberFlag
     else:
         all_flags = MemberFlag.userlevel_flags()
     return [(f, f in member.flags) for f in all_flags]
示例#4
0
文件: listobj.py 项目: pb30/LambdaMLM
 def user_own_flags(self, user):
     address = address_from_user(user)
     member = self.member_with_address(address)
     if not member:
         raise NotSubscribed
     if MemberFlag.admin in member.flags:
         all_flags = MemberFlag
     else:
         all_flags = MemberFlag.userlevel_flags()
     return [(f, f in member.flags) for f in all_flags]