本文整理汇总了Python中signups.models.Signup.save方法的典型用法代码示例。如果您正苦于以下问题:Python Signup.save方法的具体用法?Python Signup.save怎么用?Python Signup.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类signups.models.Signup
的用法示例。
在下文中一共展示了Signup.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_from_old_site
# 需要导入模块: from signups.models import Signup [as 别名]
# 或者: from signups.models.Signup import save [as 别名]
def import_from_old_site(request):
user = request.user.get_profile()
if request.method == 'POST':
form = project_forms.ImportProjectForm(request.POST)
if form.is_valid():
course = form.cleaned_data['course']
#CS - too much logic in view
project = Project(name=course['name'], kind=course['kind'],
short_description=course['short_description'],
long_description=course['long_description'],
imported_from=course['slug'])
project.save()
act = Activity(actor=user,
verb=verbs['post'],
scope_object=project,
target_object=project)
act.save()
participation = Participation(project=project, user=user,
organizing=True)
participation.save()
new_rel, created = Relationship.objects.get_or_create(source=user,
target_project=project)
new_rel.deleted = False
new_rel.save()
if course['detailed_description']:
detailed_description_content = course['detailed_description']
else:
detailed_description_content = render_to_string(
"projects/detailed_description_initial_content.html",
{'project': project})
detailed_description = Page(title=_('Full Description'),
slug='full-description', content=detailed_description_content,
listed=False, author_id=user.id, project_id=project.id)
detailed_description.save()
project.detailed_description_id = detailed_description.id
sign_up = Signup(between_participants=course['sign_up'],
author_id=user.id, project_id=project.id)
sign_up.save()
project.save()
for title, content in course['tasks']:
new_task = Page(title=title, content=content, author=user,
project=project)
new_task.save()
for name, url in course['links']:
new_link = Link(name=name, url=url, user=user, project=project)
new_link.save()
project.create()
messages.success(request,
_('The %s has been imported.') % project.kind.lower())
return http.HttpResponseRedirect(reverse('projects_show', kwargs={
'slug': project.slug,
}))
else:
msg = _("Problem importing the study group, course, ...")
messages.error(request, msg)
else:
form = project_forms.ImportProjectForm()
return render_to_response('projects/project_import.html', {
'form': form, 'import_tab': True},
context_instance=RequestContext(request))
示例2: create
# 需要导入模块: from signups.models import Signup [as 别名]
# 或者: from signups.models.Signup import save [as 别名]
def create(request, category=None):
user = request.user.get_profile()
if request.method == 'POST':
form = project_forms.ProjectForm(category, request.POST)
image_form = None
if form.is_valid():
project = form.save()
if category:
project.category = category
image_form = project_forms.ProjectImageForm(request.POST,
request.FILES, instance=project)
if image_form.is_valid():
image_form.save()
project.set_duration(form.cleaned_data['duration'] or 0)
#CS - too much logic in view
act = Activity(actor=user,
verb=verbs['post'],
scope_object=project,
target_object=project)
act.save()
participation = Participation(project=project, user=user,
organizing=True)
participation.save()
new_rel, created = Relationship.objects.get_or_create(source=user,
target_project=project)
new_rel.deleted = False
new_rel.save()
detailed_description_content = render_to_string(
"projects/detailed_description_initial_content.html",
{'project': project})
detailed_description = Page(title=_('Full Description'),
slug='full-description', content=detailed_description_content,
listed=False, author_id=user.id, project_id=project.id)
if project.category != Project.STUDY_GROUP:
detailed_description.collaborative = False
detailed_description.save()
project.detailed_description_id = detailed_description.id
sign_up = Signup(author_id=user.id, project_id=project.id)
sign_up.save()
project.create()
messages.success(request,
_('The %s has been created.') % project.kind.lower())
return http.HttpResponseRedirect(reverse('projects_create_tasks',
kwargs={'slug': project.slug,}))
else:
msg = _("Problem creating the course")
messages.error(request, msg)
else:
form = project_forms.ProjectForm(category, initial={'test':True})
image_form = project_forms.ProjectImageForm()
context = {
'form': form,
'image_form': image_form,
'category': category,
'is_challenge': (category == Project.CHALLENGE),
}
return render_to_response('projects/project_create_overview.html',
context, context_instance=RequestContext(request))
示例3: create
# 需要导入模块: from signups.models import Signup [as 别名]
# 或者: from signups.models.Signup import save [as 别名]
def create(request):
user = request.user.get_profile()
if request.method == 'POST':
form = project_forms.ProjectForm(request.POST)
if form.is_valid():
project = form.save()
act = Activity(actor=user,
verb=verbs['post'],
scope_object=project,
target_object=project)
act.save()
participation = Participation(project=project, user=user,
organizing=True)
participation.save()
new_rel, created = Relationship.objects.get_or_create(source=user,
target_project=project)
new_rel.deleted = False
new_rel.save()
detailed_description_content = render_to_string(
"projects/detailed_description_initial_content.html",
{'project': project})
detailed_description = Page(title=_('Full Description'),
slug='full-description', content=detailed_description_content,
listed=False, author_id=user.id, project_id=project.id)
if project.category != Project.STUDY_GROUP:
detailed_description.collaborative = False
detailed_description.save()
project.detailed_description_id = detailed_description.id
sign_up = Signup(author_id=user.id, project_id=project.id)
sign_up.save()
project.create()
messages.success(request,
_('The %s has been created.') % project.kind.lower())
return http.HttpResponseRedirect(reverse('projects_show', kwargs={
'slug': project.slug,
}))
else:
msg = _("Problem creating the study group, course, ...")
messages.error(request, msg)
else:
form = project_forms.ProjectForm()
return render_to_response('projects/project_edit_summary.html', {
'form': form, 'new_tab': True,
}, context_instance=RequestContext(request))