Created
June 27, 2012 13:04
-
-
Save martyzz1/3003954 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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