Пример #1
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)
Пример #2
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)
Пример #3
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())
Пример #4
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())