My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 63 attachment: bctfi.py (749 bytes)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from django.core.management.base import BaseCommand

class Command(BaseCommand):
help = "Generates html code to display categories for selecting"
requires_model_validation = False
def handle(self, **options):
from yerelilan.announce.models import Category
root=Category.objects.get(name="All")
html='<select id="id_category" name="category">\n'
option='<option style="padding-left:%spx;"%svalue="%s">{%% trans "%s" %%}</option>\n'
html+= option % (0,"DISABLED", root.id,root.name)
stack = list()
stack.extend(root.get_children())
while stack:
chunk = stack.pop()
html+= option % (chunk.level*20,[" DISABLED ",""][chunk.selectible],chunk.id,chunk.name)
stack.extend(chunk.get_children())
html+='</select>'
print html

Powered by Google Project Hosting