本文整理汇总了Python中corehq.apps.domain.models.LICENSES类的典型用法代码示例。如果您正苦于以下问题:Python LICENSES类的具体用法?Python LICENSES怎么用?Python LICENSES使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LICENSES类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: manage_multimedia
def manage_multimedia(request, domain):
media = request.project.all_media()
if request.method == "POST":
for m_file in media:
if '%s_tags' % m_file._id in request.POST:
m_file.tags[domain] = request.POST.get('%s_tags' % m_file._id, '').split(' ')
if domain not in m_file.shared_by and request.POST.get('%s_shared' % m_file._id, False):
m_file.shared_by.append(domain)
elif domain in m_file.shared_by and not request.POST.get('%s_shared' % m_file._id, False):
m_file.shared_by.remove(domain)
if '%s_license' % m_file._id in request.POST:
m_file.update_or_add_license(domain, type=request.POST.get('%s_license' % m_file._id, 'public'))
m_file.save()
messages.success(request, "Multimedia updated successfully!")
return render(request, 'domain/admin/media_manager.html', {'domain': domain,
'media': [{
'license': m.license.type if m.license else 'public',
'shared': domain in m.shared_by,
'url': m.url(),
'm_id': m._id,
'tags': m.tags.get(domain, []),
'type': m.doc_type
} for m in media],
'licenses': LICENSES.items()
})
示例2: _appstore_context
def _appstore_context(context={}):
context['sortables'] = [
('category', [(d.replace(' ', '+'), d, count) for d, count in Domain.field_by_prefix('project_type')]),
('region', [(d.replace(' ', '+'), d, count) for d, count in Domain.field_by_prefix('region')]),
('author', [(d.replace(' ', '+'), d, count) for d, count in Domain.field_by_prefix('author')]),
('license', [(d, LICENSES.get(d), count) for d, count in Domain.field_by_prefix('license')]),
]
return context
示例3: display_name
def display_name(self):
return LICENSES.get(self.type, "Improper License")
示例4: options
def options(self):
return [(code, license_name) for code, license_name in LICENSES.items()]
示例5: page_context
def page_context(self):
return {
'media': self.project_media_data,
'licenses': list(LICENSES.items()),
}
示例6: update_params
def update_params(self):
available_licenses = [{'val': code, 'text': license} for code, license in LICENSES.items()]
self.selected = self.request.GET.get(self.slug,'')
self.options = available_licenses
示例7: create_snapshot
def create_snapshot(request, domain):
domain = Domain.get_by_name(domain)
#latest_applications = [app.get_latest_saved() or app for app in domain.applications()]
if request.method == 'GET':
form = SnapshotSettingsForm(initial={
'default_timezone': domain.default_timezone,
'case_sharing': json.dumps(domain.case_sharing),
'city': domain.city,
'country': domain.country,
'region': domain.region,
'project_type': domain.project_type,
'share_multimedia': True,
'license': domain.license
})
published_snapshot = domain.published_snapshot() or domain
published_apps = {}
if published_snapshot is not None:
form = SnapshotSettingsForm(initial={
'default_timezone': published_snapshot.default_timezone,
'case_sharing': json.dumps(published_snapshot.case_sharing),
'city': published_snapshot.city,
'country': published_snapshot.country,
'region': published_snapshot.region,
'project_type': published_snapshot.project_type,
'license': published_snapshot.license,
'title': published_snapshot.title,
'author': published_snapshot.author,
'share_multimedia': True,
'description': published_snapshot.description
})
for app in published_snapshot.full_applications():
if domain == published_snapshot:
published_apps[app._id] = app
else:
published_apps[app.original_doc] = app
app_forms = []
for app in domain.applications():
app = app.get_latest_saved() or app
if published_snapshot and app._id in published_apps:
original = published_apps[app._id]
app_forms.append((app, SnapshotApplicationForm(initial={
'publish': True,
'name': original.name,
'description': original.description,
'deployment_date': original.deployment_date,
'user_type': original.user_type,
'attribution_notes': original.attribution_notes,
'phone_model': original.phone_model,
}, prefix=app.id)))
else:
app_forms.append((app, SnapshotApplicationForm(initial={'publish': (published_snapshot is None or published_snapshot == domain)}, prefix=app.id)))
return render_to_response(request, 'domain/create_snapshot.html',
{'domain': domain.name,
'form': form,
#'latest_applications': latest_applications,
'app_forms': app_forms,
'autocomplete_fields': ('project_type', 'phone_model', 'user_type', 'city', 'country', 'region')})
elif request.method == 'POST':
form = SnapshotSettingsForm(request.POST, request.FILES)
app_forms = []
publishing_apps = False
for app in domain.applications():
app = app.get_latest_saved() or app
app_forms.append((app, SnapshotApplicationForm(request.POST, prefix=app.id)))
publishing_apps = publishing_apps or request.POST.get("%s-publish" % app.id, False)
if not publishing_apps:
messages.error(request, "Cannot publish a project without applications to CommCare Exchange")
return render_to_response(request, 'domain/create_snapshot.html',
{'domain': domain.name,
'form': form,
'app_forms': app_forms,
'autocomplete_fields': ('project_type', 'phone_model', 'user_type', 'city', 'country', 'region')})
if not form.is_valid():
return render_to_response(request, 'domain/create_snapshot.html',
{'domain': domain.name,
'form': form,
#'latest_applications': latest_applications,
'app_forms': app_forms,
'autocomplete_fields': ('project_type', 'phone_model', 'user_type', 'city', 'country', 'region')})
if request.POST.get('share_multimedia', False):
media = domain.all_media()
for m_file in media:
if domain.name not in m_file.shared_by:
m_file.shared_by.append(domain.name)
m_file.licenses[domain.name] = domain.license
m_file.save()
old = domain.published_snapshot()
new_domain = domain.save_snapshot()
if request.POST['license'] in LICENSES.keys():
new_domain.license = request.POST['license']
new_domain.description = request.POST['description']
new_domain.project_type = request.POST['project_type']
new_domain.region = request.POST['region']
new_domain.city = request.POST['city']
new_domain.country = request.POST['country']
new_domain.title = request.POST['title']
new_domain.author = request.POST['author']
#.........这里部分代码省略.........
示例8: update_params
def update_params(self):
available_licenses = [{"val": code, "text": license} for code, license in LICENSES.items()]
self.selected = self.request.GET.get(self.slug, "")
self.options = available_licenses