From: hernani Date: Thu, 7 Oct 2010 15:20:17 +0000 (+0000) Subject: More data handled by the exporter, and a improved "pickled" value parsing. X-Git-Tag: live~532 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/3860fda5909f0f756be78567e4961ea82a12c4a3 More data handled by the exporter, and a improved "pickled" value parsing. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@602 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum_modules/exporter/exporter.py b/forum_modules/exporter/exporter.py index e504e40..6114355 100644 --- a/forum_modules/exporter/exporter.py +++ b/forum_modules/exporter/exporter.py @@ -88,18 +88,32 @@ def ET_Element_add_tag(el, tag_name, content = None, **attrs): GOOD_TAG_NAME = re.compile("^\w+$") -def make_extra(el, extra): - if not extra: +def make_extra(el, v): + if v is None: return - if isinstance(extra, dict): - for k, v in extra.items(): - if GOOD_TAG_NAME.match(k): - make_extra(el.add(k), v) - else: - make_extra(el.add("key", name=k), v) + + if isinstance(v, (int, long, str, float, bool, dict, list, tuple)): + if isinstance(v, tuple): + t = 'list' + else: + t = v.__class__.__name__ else: - el.text = unicode(extra) + t = 'unknown' + + value = el.add('value', type=t) + + if isinstance(v, (list, tuple)): + for i in v: + item = value.add('item') + make_extra(item, i) + + elif isinstance(v, dict): + for k, i in v.items(): + item = value.add('item', key=k) + make_extra(item, i) + else: + value.text = unicode(v) def write_to_file(root, tmp, filename): tree = ET.ElementTree(root) @@ -243,6 +257,7 @@ def export_users(u, el, anon_data): el.add('username', u.username) el.add('password', u.password) el.add('email', u.email, validated=u.email_isvalid and 'true' or 'false') + el.add('reputation', u.reputation) el.add('joindate', u.date_joined) el.add('firstname', u.first_name) @@ -266,7 +281,29 @@ def export_users(u, el, anon_data): key.add('provider', a.provider) key.add('key', a.key) - el.add('reputation', u.reputation) + + ss = u.subscription_settings + + notify = el.add('notifications', enabled=ss.enable_notifications and 'true' or 'false') + + notify.add('notify', **dict([(t, ss.__dict__.get(t, 'n') == 'i' and 'true' or 'false') for t in ['member_joins', 'new_question', 'new_question_watched_tags', 'subscribed_questions']])) + + notify.add('autoSubscribe', **dict([(t, ss.__dict__.get(t, False) and 'true' or 'false') for t in [ + 'all_questions', 'all_questions_watched_tags', 'questions_asked', 'questions_answered', 'questions_commented', 'questions_viewed']])) + + notify.add('notifyOnSubscribed', **dict([(t, ss.__dict__.get("notify_%s" % t, False) and 'true' or 'false') for t in [ + 'answers', 'reply_to_comments', 'comments_own_post', 'comments', 'accepted']])) + + notify.add('digest', ss.send_digest and 'on' or 'off') + + watched = el.add('watchedTags') + rejected = el.add('rejectedTags') + + for m in u.tag_selections.all(): + if m.reason == 'good': + watched.add('tag', m.tag.name) + else: + rejected.add('tag', m.tag.name) diff --git a/forum_modules/exporter/templates/running.html b/forum_modules/exporter/templates/running.html index 79bfc3a..5a8e2a9 100644 --- a/forum_modules/exporter/templates/running.html +++ b/forum_modules/exporter/templates/running.html @@ -102,7 +102,7 @@ {% block admincontent %}

- {% trans "Please wait while we prepare your backup file to download. Started" %} - + {% trans "Please wait while we prepare your backup file to download." %} - {% blocktrans %} Started {% endblocktrans %}