Esempio n. 1
0
    def delete(self, request, *args, **kwargs):
        self.object = self.get_object()
        if self.object.storage.method == Storage.DROPBOX:
            Dropbox.delete_file(
                self.object
            )  # TODO central location to handle storage type switches
        if self.object.storage.method == Storage.NEXTCLOUD:
            Nextcloud.delete_file(self.object)

        return super(RecipeSourceDelete, self).delete(request, *args, **kwargs)
Esempio n. 2
0
def delete_recipe_source(request, pk):
    recipe = get_object_or_404(Recipe, pk=pk)

    if recipe.storage.method == Storage.DROPBOX:
        Dropbox.delete_file(recipe)  # TODO central location to handle storage type switches
    if recipe.storage.method == Storage.NEXTCLOUD:
        Nextcloud.delete_file(recipe)

    recipe.storage = None
    recipe.file_path = ''
    recipe.file_uid = ''
    recipe.save()

    return HttpResponseRedirect(reverse('edit_recipe', args=[recipe.pk]))