本文整理汇总了Python中models.Project.title方法的典型用法代码示例。如果您正苦于以下问题:Python Project.title方法的具体用法?Python Project.title怎么用?Python Project.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Project
的用法示例。
在下文中一共展示了Project.title方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_new_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import title [as 别名]
def create_new_project(request):
"""
Takes in an ajax request to create a new project
"""
returnDict = {}
if request.method == 'POST':
print request.POST
try:
datadict = json.loads(request.POST['projectdata'])
print datadict
#we have stuff to process
project = Project()
project.title = datadict['name']
project.startDate = datetime.datetime.strptime(datadict['startDate'], "%m/%d/%Y")
project.category = datadict['category']
project.complete = False
project.save()
returnDict['id'] = project.id
except Exception, e:
print e
returnDict['error'] = e.message
示例2: insert_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import title [as 别名]
def insert_project(self):
p = Project()
p.title = "Example Project"
p.comment = "This is an example project for the Django tests"
p.save()
return p
示例3: add_or_edit_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import title [as 别名]
def add_or_edit_project(request, project_author=None, project_pk=None, is_add=False):
user = request.user
project = None
if not is_add:
project = get_object_or_404(Project, pk=project_pk)
if project.wont_be_completed:
return oops("This project is set as 'won't be completed': you can't edit it")
# only a project's author can edit it
if not user == project.author:
return oops("Only a project's author can edit it.")
if request.method == "POST":
if is_add:
project = Project(proposed_by=user, author=user)
elif project.author != user:
return oops("Only a project's author can edit it.")
form = ProjectForm(request.POST)
if form.is_valid():
project.title = form.cleaned_data["title"]
# if form.cleaned_data['event']:
# project.event = get_object_or_404(Event, pk=form.cleaned_data['event'])
project.description_markdown = form.cleaned_data["description"]
if form.cleaned_data["time_estimate"]:
project.hour_estimate = form.cleaned_data["time_estimate"]
if project.p_completed:
project.showcase_markdown = form.cleaned_data["showcase"]
if not project.p_completed:
not_involved = form.cleaned_data["not_involved"]
if not_involved:
project.looking_for_admin = True
if not is_add:
user.message_set.create(
message="The project is now set as 'looking for admin'. You have admin rights until someone else clicks 'Become admin for this project'."
)
project.remove_member(user)
else:
project.looking_for_admin = False
tags = form.cleaned_data["tags"]
project.save()
# Need to save() before calling this, so we couldn't do it up there
if is_add and not not_involved:
project.join_user(user)
project.set_tags(tags)
return HttpResponseRedirect(project.get_absolute_url())
elif not is_add:
# initialize the form with existing project info
form = ProjectForm(
initial={
"title": project.title,
"description": project.description_markdown,
"showcase": project.showcase_markdown,
"tags": project.get_editable_tags,
"time_estimate": project.hour_estimate,
}
)
else:
form = ProjectForm()
return render_to_response(
"projects/add_or_edit_project.html",
{"form": form, "is_editing": not is_add, "project": project},
context_instance=RequestContext(request),
)
示例4: fetch
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import title [as 别名]
def fetch(token, task_id=None):
session = Session()
try:
obj = Fetch(token)
print(obj.result)
t = session.query(Project).filter_by(token=token).first()
print(t)
datas = obj.result
if not t:
logging.info("Create new project")
tpl = session.query(Template).filter_by(codemodule=datas["module_code"], slug=datas["slug"]).first()
if not tpl:
logging.info("Create new Template")
tpl = Template(codemodule=datas["module_code"], slug=datas["slug"])
# repository_name, call*, school, ...
session.add(tpl)
t = Project(template=tpl)
session.add(t)
t.token = datas["token"]
t.scolaryear = datas["scolaryear"]
t.module_title = datas["module_title"]
t.module_code = datas["module_code"]
t.instance_code = datas["instance_code"]
t.location = datas["location"]
t.title = datas["title"]
t.deadline = datetime.strptime(datas["deadline"], "%Y-%m-%d %H:%M:%S")
t.promo = datas["promo"]
t.groups = json.dumps(datas["groups"])
t.last_update = datetime.now()
resp = []
for user in datas["resp"]:
u = session.query(User).filter_by(login=user["login"]).first()
if not u:
u = User(firstname=user["firstname"], lastname=user["lastname"],
login=user["login"], old_login=user["old_login"])
session.add(u)
resp.append(u)
t.resp = resp
template_resp = []
for user in datas["template_resp"]:
u = session.query(User).filter_by(login=user["login"]).first()
if not u:
u = User(firstname=user["firstname"], lastname=user["lastname"],
login=user["login"], old_login=user["old_login"])
session.add(u)
template_resp.append(u)
t.template_resp = template_resp
assistants = []
for user in datas["assistants"]:
u = session.query(User).filter_by(login=user["login"]).first()
if not u:
u = User(firstname=user["firstname"], lastname=user["lastname"],
login=user["login"], old_login=user["old_login"])
session.add(u)
assistants.append(u)
t.assistants = assistants
t.students = []
for user in datas["students"]:
u = session.query(User).filter_by(login=user["login"]).first()
if not u:
u = User(firstname=user["firstname"], lastname=user["lastname"],
login=user["login"], old_login=user["old_login"])
session.add(u)
t.students.append(Project_Student(user=u, project=t))
session.add(t)
need_new = True
for task in t.tasks:
if task.type == "auto":
need_new = False
if task.type == "auto" and task.status != "ongoing" and task.id != task_id and task_id != 0:
task.launch_date = t.deadline
task.status = "todo"
session.add(task)
if need_new:
session.add(Task(type="auto", launch_date=t.deadline, project=t))
session.commit()
return t.serialize
except IntegrityError as e:
session.rollback()
except Exception as e:
session.rollback()
logging.error(str(e))
finally:
session.close()
return False