Exemplo n.º 1
0
    def test_validate_user_owns_banner(self):
        """
        The delete form must validate that the user passed in the constructor
        owns the banner instance.
        """
        user = FacebookUserFactory.create()
        instance1 = FacebookBannerInstanceFactory.create(user=user)
        instance2 = FacebookBannerInstanceFactory.create()

        form = BannerInstanceDeleteForm(user, {'banner_instance': instance1.id})
        ok_(form.is_valid())

        form = BannerInstanceDeleteForm(user, {'banner_instance': instance2.id})
        ok_(not form.is_valid())
Exemplo n.º 2
0
    def test_validate_user_owns_banner(self):
        """
        The delete form must validate that the user passed in the constructor
        owns the banner instance.
        """
        user = FacebookUserFactory.create()
        instance1 = FacebookBannerInstanceFactory.create(user=user)
        instance2 = FacebookBannerInstanceFactory.create()

        form = BannerInstanceDeleteForm(user,
                                        {'banner_instance': instance1.id})
        ok_(form.is_valid())

        form = BannerInstanceDeleteForm(user,
                                        {'banner_instance': instance2.id})
        ok_(not form.is_valid())
Exemplo n.º 3
0
def banner_delete(request):
    form = BannerInstanceDeleteForm(request.user, request.POST)
    if form.is_valid():
        banner_instance = form.cleaned_data['banner_instance']
        banner_instance.delete()
        messages.success(request, _('Your banner has been deleted.'))
    return banner_list(request)
Exemplo n.º 4
0
def banner_delete(request):
    form = BannerInstanceDeleteForm(request.user, request.POST)
    if form.is_valid():
        banner_instance = form.cleaned_data['banner_instance']
        banner_instance.delete()
        messages.success(request, _('Your banner has been deleted.'))
    return banner_list(request)