I have some very simple views that act as forms because there is no
information to fill out.  I get all the information from the url and
the request object.

For example, I may have a model like:

class Subscription(models.Model):
    user         = models.ForeignKey(User)
    magazine = models.ForeignKey(Magazine)

So I have URL's like

r'^subscriptions/subscribe/(?P<magazine_id>[\w-]+)/$'
r'^subscriptions/unsubscribe/(?P<magazine_id>[\w-]+)/$'

My views are like...

@login_required
def subscribe(request, magazine_id):
    # get relevant objects
    magazine = get_object_or_404(Magazine, id=magazine_id)
    # retrieve subscription or create if it doesn't exist
    try:
        subscription = Subscription.objects.get(user=request.user,
magazine=magazine)
        message = 'You are already subscribed'
    except Subscription.DoesNotExist:
        subscription = Subscription(user=request.user,
magazine=magazine)
        subscription.save()
        message = 'You are now subscribed.'

    return render_to_response(
        'myapp/subscribed.html',
        {'subscription': subscription, 'message': message},
        context_instance=RequestContext(request)
    )

Okay, now finally the questions...
How can I implement an intermediate step in this process where I have
a confirmation message and an accept / cancel button?

Could a generic decorator be made to add an intermediate message.
Like ...

@disclaimer("Are you over the age of 18?")
def my_dirty_view(request):
    return SomethingDirty()

Is it bad to have a view without a form actually do stuff like
database inserts and deletes via GET rather than POST?

I have several objects similar to this example of Subscription each of
which would have their own disclaimer / warning upon creation /
deletion.

I need some suggestions.

Thanks,
~Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to