Skip to content

Commit

Permalink
Merge pull request #5190 from dimagi/improve-exchange-app-copy
Browse files Browse the repository at this point in the history
Improve efficiency of app publishing
  • Loading branch information
czue committed Jan 5, 2015
2 parents a199a41 + c153720 commit 9aed2b4
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions corehq/apps/domain/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,6 @@ def published_apps(self):
def app_forms(self):
app_forms = []
for app in self.domain_object.applications():
app = app.get_latest_saved() or app
if self.request.method == 'POST':
app_forms.append((app, SnapshotApplicationForm(self.request.POST, prefix=app.id)))
elif self.published_snapshot and app.copy_of in self.published_apps:
Expand Down Expand Up @@ -1584,7 +1583,6 @@ def snapshot_settings_form(self):
@memoized
def has_published_apps(self):
for app in self.domain_object.applications():
app = app.get_latest_saved() or app
if self.request.POST.get("%s-publish" % app.id, False):
return True
messages.error(self.request, _("Cannot publish a project without applications to CommCare Exchange"))
Expand Down Expand Up @@ -1625,16 +1623,10 @@ def post(self, request, *args, **kwargs):
if not request.POST.get('share_reminders', False):
ignore.append('CaseReminderHandler')

latest_apps = [app.get_latest_saved() or app for app in self.domain_object.applications()]
latest_apps = {app.id: app for app in latest_apps}
copy_by_id = set()
for k in request.POST.keys():
if k.endswith("-publish"):
doc_id = k[:-len("-publish")]
if doc_id in latest_apps:
doc_id = latest_apps[doc_id].copy_of or doc_id
copy_by_id.add(doc_id)

copy_by_id.add(k[:-len("-publish")])

old = self.domain_object.published_snapshot()
new_domain = self.domain_object.save_snapshot(ignore=ignore,
Expand Down

0 comments on commit 9aed2b4

Please sign in to comment.