|
|
|
@ -282,13 +282,16 @@ class CollectionInvitationSerializer(serializers.ModelSerializer):
|
|
|
|
|
def get_from_pubkey(self, obj):
|
|
|
|
|
return b64encode(obj.fromMember.user.userinfo.pubkey)
|
|
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
|
collection = self.context['collection']
|
|
|
|
|
def validate_user(self, value):
|
|
|
|
|
request = self.context['request']
|
|
|
|
|
|
|
|
|
|
if request.user == validated_data.get('user'):
|
|
|
|
|
if request.user == value:
|
|
|
|
|
raise serializers.ValidationError('Inviting yourself is not allowed')
|
|
|
|
|
|
|
|
|
|
def create(self, validated_data):
|
|
|
|
|
collection = self.context['collection']
|
|
|
|
|
request = self.context['request']
|
|
|
|
|
|
|
|
|
|
member = collection.members.get(user=request.user)
|
|
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
|
|
|