wrong django version
[redakcja.git] / apps / catalogue / management / commands / make_master.py
index fcd4c03..b262201 100644 (file)
@@ -2,6 +2,7 @@
 
 from django.core.management.base import BaseCommand
 from django.core.management.color import color_style
+from django.utils.encoding import smart_unicode
 from catalogue.management.prompt import confirm
 from catalogue.models import Book
 from optparse import make_option
@@ -22,8 +23,8 @@ dc_namespaces = { "dc": "http://purl.org/dc/elements/1.1/" }
 
 class Command(BaseCommand):
     option_list = BaseCommand.option_list + (
-        make_option('-s', '--slug', dest='slug', help="Slug for master module"),
-        make_option('-F', '--file', dest='slugs_file', help="file with child module slugs per line"),
+        make_option('-s', '--slug', dest='slug', help="Slug for master module (if empty will be generated from title)"),
+        make_option('-F', '--file', dest='slugs_file', help="file with child module titles per line"),
         make_option('-t', '--title', dest='title', default='', help="title of master module"),
         make_option('-l', '--level', dest='audience', default='', help='Audience level'),
     )
@@ -59,11 +60,11 @@ class Command(BaseCommand):
             print "type is '%s', setting to '%s'" % (typ.text, typ_)
             changed = True
             typ.text = typ_
-        audience = t.xpath("//dc:audience", namespaces=dc_namespaces)[0]
-        if audience.text != audience_:
-            print "audience is '%s', setting to '%s'" % (audience.text, audience_)
-            changed = True
-            audience.text = audience_
+        #audience = t.xpath("//dc:audience", namespaces=dc_namespaces)[0]
+        #if audience.text != audience_:
+        #    print "audience is '%s', setting to '%s'" % (audience.text, audience_)
+        #    changed = True
+        #    audience.text = audience_
         if changed:
             print "will commit."
             fc.commit(etree.tostring(t, encoding=unicode), **commit_args)
@@ -81,6 +82,7 @@ class Command(BaseCommand):
             holder['xml'] += u"%s\n" % t
 
         def dc(k, v):
+            v = smart_unicode(v)
             p(u'<dc:%s xml:lang="pl" xmlns:dc="http://purl.org/dc/elements/1.1/">%s</dc:%s>' % (k, v, k))
 
         def t(tag, ct):
@@ -111,9 +113,8 @@ class Command(BaseCommand):
         dc(u'rights', dc_fixed['rights'])
         dc(u'rights.license', dc_fixed['rights_license'])
         dc(u'format', u'xml')
-        dc(u'type', u'text')
+        dc(u'type', u'section')
         dc(u'date', date.strftime(date.today(), "%Y-%m-%d"))
-        dc(u'audience', options['audience'])
         dc(u'language', u'pol')
         p(u'</rdf:Description>')
         p(u'</rdf:RDF>')