Пример #1
0
def information(request, task):
    titleForm = TitleForm()
    if request.method == 'POST':
        titleForm = TitleForm(request.POST)
        if titleForm.is_valid():
            print "before lock in information " + str(request.user.id)
            lock = FileLock("/home/senderma/projects/banalnosti/lockAddTitle")
            with lock:
                print "in information " + str(request.user.id)
                if(len(titleForm.cleaned_data['title'].split()) > 0):
                    print "count information " + str(request.user.id)
                    titleInput = titleForm.cleaned_data['title']
                    userTitle = Titles.objects.filter(gameID = task.gameID, user = request.user)
                    if(len(userTitle) != 1 or userTitle[0].title != titleInput):
	                    Titles.objects.filter(gameID = task.gameID, user = request.user).delete()
	                    titlesNew = Titles(user = request.user, title = titleInput, gameID = task.gameID, tourID = -1)
	                    titlesNew.save()
                print "out information " + str(request.user.id)
                time.sleep(1)	
    if len(Titles.objects.filter(gameID = task.gameID, user = request.user)) > 0:
        titleYour = Titles.objects.filter(gameID = task.gameID, user = request.user)[0]
    
	#для html    
    peoplesInputTitles = map(lambda x: x.user, Titles.objects.filter(gameID = task.gameID))
    currentTime = timezone.now()
    taskNext = Tasks.objects.filter(taskTime__gt = task.taskTime).order_by('taskTime')[0]   
    NUMBER_SEC_REDIRECT = taskNext.taskTime - currentTime
    NUMBER_SEC_REDIRECT = NUMBER_SEC_REDIRECT.days*60*60*24 + NUMBER_SEC_REDIRECT.seconds + 1
    NEXT_PAGE = '/main/'
    message = "До игры осталось"
    return render_to_response('info.html', locals(), context_instance=RequestContext(request))
Пример #2
0
def add_sequencelisting(request):
    if request.method == 'POST':
        form = SequenceListingForm(request.POST)
        title_form = TitleForm(request.POST)

        if form.is_valid() and title_form.is_valid():
            filingDateFromForm = request.POST.get('filingDate')
            #             set to None bc the model does not handle properly empty string from form
            fd = filingDateFromForm if filingDateFromForm else None

            sl_instance = SequenceListing.objects.create(
                fileName=request.POST.get('fileName'),
                dtdVersion='1',
                softwareName='prototype',
                softwareVersion='0.1',
                productionDate=timezone.now(
                ),  #should be overwritten upon xml export
                applicantFileReference=request.POST.get(
                    'applicantFileReference'),
                IPOfficeCode=request.POST.get('IPOfficeCode'),
                applicationNumberText=request.POST.get(
                    'applicationNumberText'),
                #             filingDate = request.POST.get('filingDate'),
                filingDate=fd,
                earliestPriorityIPOfficeCode=request.POST.get(
                    'earliestPriorityIPOfficeCode'),
                earliestPriorityApplicationNumberText=request.POST.get(
                    'earliestPriorityApplicationNumberText'),
                earliestPriorityFilingDate=request.POST.get(
                    'earliestPriorityFilingDate'),
                applicantName=request.POST.get('applicantName'),
                applicantNameLanguageCode=request.POST.get(
                    'applicantNameLanguageCode'),
                applicantNameLatin=request.POST.get('applicantNameLatin'),
                inventorName=request.POST.get('inventorName'),
                inventorNameLanguageCode=request.POST.get(
                    'inventorNameLanguageCode'),
                inventorNameLatin=request.POST.get('inventorNameLatin'),
            )

            sl_instance.save()

            tcd = title_form.cleaned_data
            title_instance = Title(
                sequenceListing=sl_instance,
                inventionTitle=tcd['inventionTitle'],
                inventionTitleLanguageCode=tcd['inventionTitleLanguageCode'])

            title_instance.save()

            return HttpResponseRedirect(
                reverse('sequencelistings:edit_seql', args=(sl_instance.pk, )))
    else:
        form = SequenceListingForm()
        title_form = TitleForm()

    return render(request, 'sequencelistings/add_sequencelisting.html', {
        'form': form,
        'title_form': title_form
    })
Пример #3
0
def add_sequencelisting(request):
    if request.method == 'POST':
        form = SequenceListingForm(request.POST)
        title_form = TitleForm(request.POST)

        if form.is_valid() and title_form.is_valid():
            filingDateFromForm = request.POST.get('filingDate')
#             set to None bc the model does not handle properly empty string from form
            fd = filingDateFromForm if filingDateFromForm else None
            
            sl_instance = SequenceListing.objects.create(
            fileName = request.POST.get('fileName'),
            dtdVersion = '1',
            softwareName = 'prototype',
            softwareVersion = '0.1',
            productionDate = timezone.now(), #should be overwritten upon xml export
            
            applicantFileReference = request.POST.get('applicantFileReference'),
     
            IPOfficeCode = request.POST.get('IPOfficeCode'),
            applicationNumberText = request.POST.get('applicationNumberText'),
#             filingDate = request.POST.get('filingDate'),
            filingDate = fd,
            
            earliestPriorityIPOfficeCode = request.POST.get('earliestPriorityIPOfficeCode'),
            earliestPriorityApplicationNumberText = request.POST.get('earliestPriorityApplicationNumberText'),
            earliestPriorityFilingDate = request.POST.get('earliestPriorityFilingDate'),
         
            applicantName = request.POST.get('applicantName'),
            applicantNameLanguageCode = request.POST.get('applicantNameLanguageCode'),
            applicantNameLatin = request.POST.get('applicantNameLatin'),
         
            inventorName = request.POST.get('inventorName'),
            inventorNameLanguageCode = request.POST.get('inventorNameLanguageCode'),
            inventorNameLatin = request.POST.get('inventorNameLatin'),
            )
            
            sl_instance.save()
            
            tcd = title_form.cleaned_data
            title_instance = Title(sequenceListing = sl_instance,
                inventionTitle = tcd['inventionTitle'],
                inventionTitleLanguageCode = tcd['inventionTitleLanguageCode']
                )
            
            title_instance.save()
            
            return HttpResponseRedirect(reverse('sequencelistings:detail', 
                                                args=(sl_instance.pk,)))
    else:
        form = SequenceListingForm()
        title_form = TitleForm()
        
    return render(request, 'sequencelistings/add_sequencelisting.html', 
                  {'form': form, 'title_form': title_form})
Пример #4
0
def custom_form_view(request):
    if request.method == 'POST':
        form = TitleForm(request.POST)
        if form.is_valid():
            # form.save()
            return redirect('/forms')
    else:
        form = TitleForm()
    time.sleep(2)
    return render(request, 'forms/form.html', {'form': form.as_p(),
                                               'action': '/forms/custom'})
Пример #5
0
def create(request):
    if request.POST:
        form = TitleForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/titles/all')
    else:
        form = TitleForm()

    args = {}
    args.update(csrf(request))

    args['form'] = form

    return render_to_response('create_title.html', args)
Пример #6
0
def add_title(request, pk):
    if request.method == 'POST':
        form = TitleForm(request.POST)

        if form.is_valid():
            sl = SequenceListing.objects.get(pk=pk)
            cd = form.cleaned_data
            
            title_instance = Title(sequenceListing = sl,
                inventionTitle = cd['inventionTitle'].encode('utf-8'),
                inventionTitleLanguageCode = cd['inventionTitleLanguageCode']
                )
            title_instance.save()
            
            return HttpResponseRedirect(reverse('sequencelistings:detail', args=(pk,)))
    else:
        form = TitleForm()
    return render(request, 'sequencelistings/add_title.html', {'form': form, 'pk': pk})
Пример #7
0
def add_title(request, pk):
    if request.method == 'POST':
        form = TitleForm(request.POST)

        if form.is_valid():
            sl = SequenceListing.objects.get(pk=pk)
            cd = form.cleaned_data

            title_instance = Title(
                sequenceListing=sl,
                inventionTitle=cd['inventionTitle'].encode('utf-8'),
                inventionTitleLanguageCode=cd['inventionTitleLanguageCode'])
            title_instance.save()

            return HttpResponseRedirect(
                reverse('sequencelistings:edit_seql', args=(pk, )))
    else:
        form = TitleForm()
    return render(request, 'sequencelistings/add_title.html', {
        'form': form,
        'pk': pk
    })
Пример #8
0
def start(request):
    id_tour = (cur_time() - time_start()) / (length_game())
    time = time_start()
    temp = request.user.username
    formTitle = TitleForm()
    isTitle = False
    if request.method == 'POST':
        formTitle = TitleForm(request.POST)
        if len(Player.objects.filter(name = temp)) == 0:
            player = Player(name = request.user.username, point = 0)
            player.save()
        if  formTitle.is_valid():
            inputTitle = formTitle.cleaned_data['title'].split() 
            if(len(inputTitle) > 0):
                VersionTitles.objects.filter(user = request.user).delete()
                isTitle = formTitle.cleaned_data['title']
                title = VersionTitles(user = request.user, title = formTitle.cleaned_data['title'], mark = 0)
                title.save()
    list_player = Player.objects.all()
    namePlayers = []
    for player in list_player:
        namePlayers.append(User.objects.get(username = player.name).first_name + " " + User.objects.get(username=player.name).last_name)
    NUMBER_SEC_REDIRECT = time - cur_time()
    return render_to_response('start.html', dict({'message': "До игры осталось", 'NEXT_PAGE': '/write.words/', 'NUMBER_SEC_REDIRECT':NUMBER_SEC_REDIRECT}, **locals()))