allura
修订版 | 85e237ad40ccfbd1987fe2641a1269d5cba3f141 (tree) |
---|---|
时间 | 2011-06-10 23:53:41 |
作者 | Dave Brondsema <dbrondsema@geek...> |
Commiter | Dave Brondsema |
[#2237] query project including nbhd; option to not make Download app; use import_id when loading threads
Signed-off-by: Dave Brondsema <dbrondsema@geek.net>
@@ -59,6 +59,7 @@ def main(): | ||
59 | 59 | list_project_ids=False, |
60 | 60 | neighborhood=None, |
61 | 61 | neighborhood_shortname=None, |
62 | + use_thread_import_id_when_reloading=False, | |
62 | 63 | skip_wiki=False, |
63 | 64 | skip_frs_download=False, |
64 | 65 | skip_unsupported_check=False) |
@@ -291,7 +292,7 @@ def create_project(pid, nbhd): | ||
291 | 292 | log.info('Loading: %s %s %s' % (pid, data.data.title, data.data.path)) |
292 | 293 | shortname = convert_project_shortname(data.data.path) |
293 | 294 | |
294 | - project = M.Project.query.get(shortname=shortname) | |
295 | + project = M.Project.query.get(shortname=shortname, neighborhood_id=nbhd._id) | |
295 | 296 | if not project: |
296 | 297 | private = (data.access_level == 'private') |
297 | 298 | log.debug('Creating %s private=%s' % (shortname, private)) |
@@ -347,7 +348,7 @@ def create_project(pid, nbhd): | ||
347 | 348 | |
348 | 349 | if not options.skip_wiki and 'wiki' in dirs: |
349 | 350 | import_wiki(project, pid, nbhd) |
350 | - if not project.app_instance('downloads'): | |
351 | + if not options.skip_frs_download and not project.app_instance('downloads'): | |
351 | 352 | project.install_app('Downloads', 'downloads') |
352 | 353 | if 'forum' in dirs: |
353 | 354 | import_discussion(project, pid, frs_mapping, shortname, nbhd) |
@@ -437,6 +438,7 @@ def import_discussion(project, pid, frs_mapping, sf_project_shortname, nbhd): | ||
437 | 438 | if not discuss_app: |
438 | 439 | discuss_app = project.install_app('Discussion', 'discussion') |
439 | 440 | h.set_context(project.shortname, 'discussion', neighborhood=nbhd) |
441 | + assert c.app | |
440 | 442 | # set permissions and config options |
441 | 443 | role_admin = M.ProjectRole.by_name('Admin')._id |
442 | 444 | role_developer = M.ProjectRole.by_name('Developer')._id |
@@ -471,15 +473,23 @@ def import_discussion(project, pid, frs_mapping, sf_project_shortname, nbhd): | ||
471 | 473 | if '.json' == ending and topic_name in topics: |
472 | 474 | fo_num_topics += 1 |
473 | 475 | topic_data = loadjson(pid, 'forum', forum_name, topic) |
474 | - to = DM.ForumThread.query.get( | |
476 | + thread_query = dict( | |
475 | 477 | subject=topic_data.title, |
476 | 478 | discussion_id=fo._id, |
477 | 479 | app_config_id=discuss_app.config._id) |
480 | + if not options.skip_thread_import_id_when_reloading: | |
481 | + # temporary/transitional. Just needed the first time | |
482 | + # running with this new code against an existing import | |
483 | + # that didn't have import_ids | |
484 | + thread_query['import_id'] = topic_data.id | |
485 | + to = DM.ForumThread.query.get(**thread_query) | |
478 | 486 | if not to: |
479 | 487 | to = DM.ForumThread( |
480 | 488 | subject=topic_data.title, |
481 | 489 | discussion_id=fo._id, |
490 | + import_id=topic_data.id, | |
482 | 491 | app_config_id=discuss_app.config._id) |
492 | + to.import_id=topic_data.id | |
483 | 493 | to_num_replies = 0 |
484 | 494 | oldest_post = None |
485 | 495 | newest_post = None |
@@ -495,6 +505,7 @@ def import_discussion(project, pid, frs_mapping, sf_project_shortname, nbhd): | ||
495 | 505 | thread_id=to._id, |
496 | 506 | discussion_id=fo._id, |
497 | 507 | app_config_id=discuss_app.config._id) |
508 | + | |
498 | 509 | if not p: |
499 | 510 | p = DM.ForumPost( |
500 | 511 | _id='%s%s@import' % (post_name,str(discuss_app.config._id)), |
@@ -909,6 +920,10 @@ def get_parser(defaults): | ||
909 | 920 | '--n-shortname', dest='neighborhood_shortname', |
910 | 921 | help='Neighborhood shortname, for PFS extract SQL') |
911 | 922 | optparser.add_option( |
923 | + '--skip-thread-import-id-when-reloading', action='store_true', | |
924 | + dest='skip_thread_import_id_when_reloading' | |
925 | + ) | |
926 | + optparser.add_option( | |
912 | 927 | '--skip-frs-download', action='store_true', dest='skip_frs_download') |
913 | 928 | optparser.add_option( |
914 | 929 | '--skip-wiki', action='store_true', dest='skip_wiki') |