Exemple #1
0
def mail_item_to_friend_form(request, content_type_id, object_id):
    """
    Displays the mail item to a friend form. (Login required)

    **Context:**

    ``form``
        The mail item to a friend form.
    ``object``
        The model instance to be mailed.
    ``content_type``
        An instance of :model:`contenttypes.ContentType` for the object.

    **Template**

    mailfriend/form.html
    
    """

    try:
        content_type, obj = generic_object_get(int(content_type_id),
                                               int(object_id))
        obj.get_absolute_url()
    except (ObjectDoesNotExist, AttributeError):
        raise Http404, "Invalid -- the object ID was invalid or does not have a get_absolute_url() method"
    initial_data = {'content_type': content_type.pk, 'object_id': obj.pk}
    form = MailedItemForm(initial=initial_data)
    context = {
        'content_type': content_type,
        'form': form,
        'object': obj,
    }
    return render_to_response('mailfriend/form.html',
                              context,
                              context_instance=RequestContext(request))
def mail_item_to_friend_form(request, content_type_id, object_id):
    """
    Displays the mail item to a friend form. (Login required)

    **Context:**

    ``form``
        The mail item to a friend form.
    ``object``
        The model instance to be mailed.
    ``content_type``
        An instance of :model:`contenttypes.ContentType` for the object.

    **Template**

    mailfriend/form.html
    
    """

    try:
        content_type, obj = generic_object_get(int(content_type_id), 
                                               int(object_id))
        obj.get_absolute_url()
    except (ObjectDoesNotExist, AttributeError):
        raise Http404, "Invalid -- the object ID was invalid or does not have a get_absolute_url() method"
    initial_data = {'content_type':content_type.pk, 'object_id':obj.pk}
    form = MailedItemForm(initial=initial_data)
    context = {
        'content_type': content_type,
        'form': form,
        'object': obj,
    }
    return render_to_response('mailfriend/form.html', 
                              context, context_instance=RequestContext(request))
Exemple #3
0
 def check_generic_object(self):
     """
     Check that the generic object exists.
     
     If it doesn't, we bail early
     """
     ct_pk = int(self.data['content_type'])
     obj_pk = int(self.data['object_id'])
     return generic_object_get(ct_pk, obj_pk)
Exemple #4
0
 def check_generic_object(self):
     """
     Check that the generic object exists.
     
     If it doesn't, we bail early
     """
     ct_pk = int(self.data['content_type'])
     obj_pk = int(self.data['object_id'])
     return generic_object_get(ct_pk, obj_pk)