Пример #1
0
def manage_lists(request, list_id=None):
    """
    Update or create a list.
    
    Handles the POST for the create/edit page, and displaies the correct form.
    """

    if list_id:
        list_object = get_object_or_404(models.List, pk=list_id, user=request.user)
    else:
        list_object = models.List(user=request.user)
    
    form = forms.ListForm(instance=list_object)

    if request.POST:
        form = forms.ListForm(request.POST, instance=list_object)
        if form.is_valid():
            if request.session.get('list_name'):
                lists.save_items(list_object, request.session.get('list_name'))
            
            form.save()
            lists.delete_list(request)
            return HttpResponseRedirect(form.instance.get_absolute_url())

    return render_to_response(
        'edit.html', 
            {
                'new_list_form': form, 
            }, context_instance = RequestContext(request))
Пример #2
0
async def delete_list(ctx, name: str):
    try:
        lists.delete_list(name)
        await ctx.send(embed=embeds.SuccessEmbed('List deleted'))
    except lists.ListNotFound:
        await ctx.send(embed=embeds.ErrorEmbed('List does not exist'))
    except Exception as e:
        await ctx.send(embed=embeds.ErrorEmbed(e))
Пример #3
0
def deactivate(request):
    if request.POST.get('deactivate_confirm'):
        if request.POST['deactivate_confirm'].lower().startswith("save"):
            if request.session.get('list_object', None):
                list_id = request.session['list_object'].pk
            else:
                list_id = None
            return HttpResponseRedirect(reverse('save_list', kwargs={'list_id' : list_id} ))
        lists.delete_list(request)
        # request.notifications.add("Your list has been deactivated")
        return HttpResponseRedirect(reverse('lists_home'))
    return render_to_response(
        'deactivate_warning.html',
        {},
        context_instance = RequestContext(request)
        )