Browse files

Adding proper URL to add_image form.

  • Loading branch information...
1 parent f75bb46 commit 0afbe9ded0766c52be55c7758df1f28007072afc @lukeman lukeman committed Dec 2, 2010
Showing with 15 additions and 1 deletion.
  1. +4 −1 mimesis/templatetags/mimesis_tags.py
  2. +11 −0 mimesis/views.py
View
5 mimesis/templatetags/mimesis_tags.py
@@ -1,9 +1,11 @@
from django import template
-from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import smart_unicode
+from django.contrib.contenttypes.models import ContentType
+
from mimesis.models import ImageAssociation, AudioAssociation, VideoAssociation
from mimesis.forms import ImageForm, AudioForm
+from mimesis.views import image_add_url
register = template.Library()
@@ -121,6 +123,7 @@ def get_video_list(parser, token):
def image_form(context, obj=None):
return {
"form": ImageForm(),
+ "form_url": image_add_url(obj),
"next": context["request"].build_absolute_uri(),
}
View
11 mimesis/views.py
@@ -1,3 +1,4 @@
+from django.core.urlresolvers import reverse
from django.db.models import get_model
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
@@ -10,6 +11,16 @@
from mimesis.forms import AudioForm, AudioAssociationForm
from mimesis.models import Image, Audio, Video
+def image_add_url(obj=None):
+ kwargs = {}
+ if obj:
+ kwargs={
+ 'app_label': obj._meta.app_label,
+ 'module_name': obj._meta.module_name,
+ 'pk': obj.pk
+ }
+ return reverse('add_image', kwargs=kwargs)
+
@login_required
@require_POST

0 comments on commit 0afbe9d

Please sign in to comment.