Beispiel #1
0
def index(request):
    try:
        theme = Theme.objects.latest()
        context = {}
        context['theme'] = theme
    except:
        return mp_render(request,'404.html')
    else:
        #return HttpResponse(utils.a())
        return mp_render(request,'index.html',context)
Beispiel #2
0
def index(request):
    try:
        theme = Theme.objects.latest()
        context = {}
        context['theme'] = theme
    except:
        return mp_render(request, '404.html')
    else:
        #return HttpResponse(utils.a())
        return mp_render(request, 'index.html', context)
Beispiel #3
0
def projectli(request):
    result = []
    ens = Environment.objects.all()
    for en in ens:
        projs = Project.objects.filter(environment=en)
        for pr in projs:
            hosts = Host.objects.filter(project=pr)
            pr.hosts = hosts
        result.append([en, projs])
    return mp_render(request, 'project_li.html', {'result': result})
Beispiel #4
0
def question(request,theme_id,question_num=0):
	try:
		theme = Theme.objects.get(id=theme_id)
		question_num = int(question_num)
		if(theme.question_num<=question_num):
			return mp_render(request,'finish.html')
		else:
			questions	= Question.objects.filter(theme_id=theme_id)[question_num:question_num+1]
			for question in questions:pass
			answers		= Answer.objects.filter(question_id=question.id)

			context 	= {}
			context['answers']	= answers
			context['question']	= question
			context['theme_id']	= theme_id
			context['question_num']	= question_num+1
			return mp_render(request,'question.html',context)
	except:
		return render(request,'404.html')		
Beispiel #5
0
def index(request, question_id):
    try:
        question = Question.objects.get(id=question_id)
        answers = Answer.objects.filter(question_id=question_id)

        context = {}
        context['answers'] = answers
        context['question'] = question
    except:
        return render(request, '404.html')
    else:
        return mp_render(request, 'question.html', context)
Beispiel #6
0
def question(request, theme_id, question_num=0):
    try:
        theme = Theme.objects.get(id=theme_id)
        question_num = int(question_num)
        if (theme.question_num <= question_num):
            return mp_render(request, 'finish.html')
        else:
            questions = Question.objects.filter(
                theme_id=theme_id)[question_num:question_num + 1]
            for question in questions:
                pass
            answers = Answer.objects.filter(question_id=question.id)

            context = {}
            context['answers'] = answers
            context['question'] = question
            context['theme_id'] = theme_id
            context['question_num'] = question_num + 1
            return mp_render(request, 'question.html', context)
    except:
        return render(request, '404.html')
Beispiel #7
0
def index(request,question_id):
	try:
		question	= Question.objects.get(id=question_id)
		answers		= Answer.objects.filter(question_id=question_id)

		context 	= {}
		context['answers']	= answers
		context['question']	= question
	except:
		return render(request,'404.html')
	else:
		return mp_render(request,'question.html',context)
Beispiel #8
0
def getDepResult(request, id):
    task = Task.objects.get(pk=id)
    environment = task.environment
    project = task.project
    hosts = project.hosts.all()
    return mp_render(
        request, 'stg_dep_results.html', {
            'environment': environment,
            'project': project,
            'hosts': hosts,
            'tid': task.id,
            'gitbranch': task.gitbranch
        })
Beispiel #9
0
def taskli(request):
    creator = request.COOKIES.get('username')
    #task_list = Task.objects.filter(creator=creator).order_by('-createtime')
    task_list = Task.objects.all().order_by('-createtime')
    paginator = Paginator(task_list, 15)

    page = request.GET.get('page')
    try:
        tasks = paginator.page(page)
    except PageNotAnInteger:
        tasks = paginator.page(1)
    except EmptyPage:
        tasks = paginator.page(paginator.num_pages)
    return mp_render(request, 'task_li.html', {'tasks': tasks})
Beispiel #10
0
def stgdep(request):
    environments = Environment.objects.all()
    for en in environments:
        #environment status 0 is 空闲, 1 is 使用中
        if en.status == 0:
            en.user = '******'
            en.usetime = ' '
            en.hstatus = '空闲'
            en.handle = '领用'
        if en.status == 1:
            try:
                task = Task.objects.filter(
                    environment=en,
                    status=0).order_by('-createtime').distinct()[0]
                en.user = task.nick
                en.usetime = task.createtime
                en.hstatus = '使用中'
                if request.COOKIES.get('username') == task.creator:
                    en.handle = '关闭'
            except Exception as e:
                print(e)

        en.save()
    return mp_render(request, 'stg_dep.html', {'environments': environments})
Beispiel #11
0
def getTask(request, id):
    try:
        id = int(id)
    except Exception as e:
        print(e)
    return mp_render(request, 'get_task.html', {'environment_id': id})
Beispiel #12
0
def taskDetail(request, tid):
    task = Task.objects.get(pk=tid)
    logs = Log.objects.filter(task=task)
    return mp_render(request, 'task_detail.html', {'task': task, 'logs': logs})