科研项目管理系统代码
科研项目管理系统是一种用于管理科研项目的软件系统,它可以帮助科学家和研究人员更好地组织和管理他们的工作。一个好的科研项目管理系统可以提高工作的效率,减少错误率,并为研究人员提供更好的支持。
下面是一个简单的科研项目管理系统的代码示例,它使用了 Python 和 Django 框架来构建。这个系统可以用于管理项目的名称、预算、进度和报告。
“`python
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from django.urls import path
from.forms import ProjectForm
from.models import Project
def index(request):
if request.method == \’POST\’:
form = ProjectForm(request.POST)
if form.is_valid():
# 处理 form 的响应数据
project = form.save(commit=False)
project.name = request.POST[\’name\’]
project. budget = request.POST[\’budget\’]
project.status = request.POST[\’status\’]
project.order = request.POST[\’order\’]
project.report = request.POST[\’report\’]
project.save()
return HttpResponse(\’Project saved successfully!\’)
else:
form = ProjectForm()
return render(request, \’index.html\’, {\’form\’: form})
@login_required
def login(request):
if request.method == \’POST\’:
username = request.POST[\’username\’]
password = request.POST[\’password\’]
if username == \’admin\’ and password == \’password\’:
return HttpResponse(\’User login successful!\’)
else:
return HttpResponse(\’Invalid username or password.\’)
else:
username = request.GET[\’username\’]
password = request.GET[\’password\’]
user = User.objects.get(username=username)
if user is not None and user.password == password:
return HttpResponse(\’User login successful!\’)
else:
return HttpResponse(\’Invalid username or password.\’)
@login_required
def logout(request):
user = User.objects.get(username=request.GET[\’username\’])
user.delete()
return HttpResponse(\’User logged out.\’)
@login_required
def signup(request):
if request.method == \’POST\’:
username = request.POST[\’username\’]
password = request.POST[\’password\’]
if username == \’admin\’ and password == \’password\’:
user = User.objects.create(username=username, password=password)
return HttpResponse(\’User created successfully!\’)
else:
return HttpResponse(\’Invalid username or password.\’)
else:
username = request.GET[\’username\’]
password = request.GET[\’password\’]
user = User.objects.get(username=username)
if user is None:
return HttpResponse(\’User not found.\’)
return render(request,\’signup.html\’, {\’user\’: user})
@login_required
def report(request):
if request.method == \’POST\’:
project = Project.objects.get(id=request.POST[\’id\’])
if project is not None:
# 处理 form 的响应数据
report = project.report
# 生成报告
report_html = \’
报告
报告内容:\’+ report + \’
\’
return HttpResponse(report_html)
else:
return HttpResponse(\’Project not found.\’)
else:
project = request.GET[\’id\’]
if project is not None:
# 处理 form 的响应数据
report = project.report
# 生成报告
report_html = \’
报告
报告内容:\’+ report + \’
\’
return HttpResponse(report_html)
else:
return HttpResponse(\’Project not found.\’)
@login_required
def view
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。