Skip to content

Instantly share code, notes, and snippets.

@martyzz1
Created June 27, 2012 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martyzz1/3003954 to your computer and use it in GitHub Desktop.
Save martyzz1/3003954 to your computer and use it in GitHub Desktop.
def linkable_content(request):
if not request.user.is_staff:
return HttpResponseForbidden()
linkable = {
'0_Country': {},
'1_Section': {},
'2_Article': {},
'3_StaticPage': {}
}
optionsdict = {'translations__is_approved': True}
for c in Country.objects.filter(**optionsdict):
linkable['0_Country']['c' + str(c.id)] = "Country: " + c.translation.name
if request.GET.get('c_id', False):
optionsdict['destination_country__id'] = int(request.GET.get('c_id', False))
for s in Section.objects.filter(**optionsdict):
linkable['1_Section']['s' + str(s.id)] = "Section: " + s.translation.title
for a in Article.objects.filter(**optionsdict):
linkable['2_Article']['a' + str(a.id)] = "Article: " + a.translation.title
for p in StaticPage.objects.filter(**optionsdict):
linkable['3_StaticPage']['p' + str(p.id)] = "StaticPage: " + p.translation.title
return linkable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment