Пример #1
0
 def add_nobit(self, nobit, external_version_number):
     nobit.save()
     self.latest_internal_version_number += 1
     if nobit.replaced:
         replaced_nobit = nobit.replaced
         delete_first_child = replaced_nobit
         delete_first_parent = replaced_nobit.parent
         delete_second_parent = first_delete_child
         delete_second_child = replaced_nobit.get_child()
         add_first_parent = delete_first_parent
         add_first_child = nobit
         add_second_parent = nobit
         add_second_child = delete_second_child
         change_parent_of_nobit = delete_second_child
         
         replaced_nobit.parent = None
         replaced_nobit.save() # do we need this step?
         
     else:
         delete_first_parent = nobit.parent
         delete_first_child = delete_first_parent.get_child()
         delete_second_parent = None
         delete_second_child = None
         add_first_parent = delete_first_parent
         add_first_child = nobit
         add_second_parent = nobit
         add_second_child = add_first_child
         change_parent_of_nobit = delete_first_child
     
     change_parent_of_nobit.parent = nobit
     change_parent_of_nobit.save() # do we need this step?
     
     edge_operations_model = get_model_from_settings(settings.EDGE_OPERATIONS_MODEL)
     new_operation = edge_operations_model(quiki = self,
         internal_version_number = self.latest_internal_version_number, 
         external_version_number = external_version_number,
         delete_first_parent = delete_first_parent.pk
         delete_first_child = delete_first_child.pk
         delete_second_parent = delete_second_parent.pk
         delete_second_child = delete_second_child.pk
         add_first_parent = add_first_parent.pk
         add_first_child = add_first_child.pk
         add_second_parent = add_second_parent.pk
         add_second_child = add_second_child.pk)
     new_operation.save()
Пример #2
0
    def get_version_dict(self, version_number):

        edge_operations_model = get_model_from_settings(settings.EDGE_OPERATIONS_MODEL)
        operations = edge_operations_model.objects.get(quiki=self)
        operations = operations.filter(internal_version_number__lte = version_number)
        operations = operations.order_by('internal_version_number')
        version_dict = {}

        for each in operations:
            try:
                del version_dict[each.delete_first_parent]
                del version_dict[each.delete_second_parent]
            except KeyError:
                pass

            if each.add_first_parent:
                version_dict[each.add_first_parent] = each.add_first_child
            if each.add_second_parent:
                version_dict[each.add_second_parent] = each.add_second_child

        return version_dict
Пример #3
0
    def get(self, request, uuid, *args, **kwargs):
        """
        Function : Used for verifying the password reset link. Returns the token 
        corresponding to the user and some other useful information when the link is
        successfully verified.
        
        Permission : Anonymous. Everyone is allowed access
        
        ---
        
        omit_parameters:
            - path
        
        type:
            token:
                required: true
                type: string
                description: token used for http Token Authentication
            link:
                required: true
                type: url
                description: POST to this link with the correct token to reset \
                the password 
               
        """
    
        password_reset_link_model = get_model_from_settings(settings.PASSWORD_RESET_LINK_MODEL)

        obj = get_object_or_404(password_reset_link_model, uuid = uuid)
        print obj
        user = obj.creator
        uri_name = user.uri_name
        token, created = Token.objects.get_or_create(user=user)
        obj.delete()
        return Response({
                        'token': token.key, 
                        'link' : reverse('accounts:password',
                            kwargs = {'uri_name' : uri_name}, request = request), 
                        }
                        )