Exemple #1
0
def submit_paper(request, abstract_id=1):
	user = request.user
	inst = Abstract.objects.get(id=abstract_id)
        
	if inst.author.user.id != user.id:
            return HttpResponseRedirect(reverse('dashboard'))
        else:
            submitted = False
            if request.method =='POST':
                abstract_form = AbstractForm(data=request.POST, instance=inst)
                if abstract_form.is_valid():
                    abstract = abstract_form.save(commit=False)

                    if 'upload' in request.FILES:
                        abstract.upload = request.FILES['upload']
                        
                    abstract.save()

                    submitted = True
                    return HttpResponseRedirect(reverse('dashboard'))

                else:
                    print abstract_form.errors

            else:
                abstract_form = AbstractForm(instance=inst)

            return render(request, 'submit_paper.html', {'abstract_form': abstract_form})
Exemple #2
0
def submit_abstract(request):
    submitted = False

    if request.method == 'POST':
        abstract_form = AbstractForm(data=request.POST)

        if abstract_form.is_valid():
            abstract = abstract_form.save(commit=False)
            abstract.author = UserProfile.objects.get(user=request.user)

            if 'upload' in request.FILES:
                abstract.upload = request.FILES['upload']

            abstract_form.save()

            submitted = True

        else:
            print abstract_form.errors

    else:
        abstract_form = AbstractForm()

    return render(request, 'submit_abstract.html', {
        'abstract_form': abstract_form,
        'submitted': submitted
    })
Exemple #3
0
def submit_paper(request, abstract_id=1):
    user = request.user
    inst = Abstract.objects.get(id=abstract_id)

    if inst.author.user.id != user.id:
        return HttpResponseRedirect(reverse('dashboard'))
    else:
        submitted = False
        if request.method == 'POST':
            abstract_form = AbstractForm(data=request.POST, instance=inst)
            if abstract_form.is_valid():
                abstract = abstract_form.save(commit=False)

                if 'upload' in request.FILES:
                    abstract.upload = request.FILES['upload']

                abstract.save()

                submitted = True

            else:
                print abstract_form.errors

        else:
            abstract_form = AbstractForm(instance=inst)

        return render(request, 'submit_paper.html',
                      {'abstract_form': abstract_form})
Exemple #4
0
def submit_abstract(request):
    submitted = False

    if request.method == 'POST':
        abstract_form = AbstractForm(data=request.POST)
		
        if abstract_form.is_valid():
			abstract = abstract_form.save(commit=False)
			abstract.author = UserProfile.objects.get(user=request.user)

			if 'upload' in request.FILES:
			   abstract.upload = request.FILES['upload']

			abstract_form.save()

			submitted = True

        else:
			print abstract_form.errors
    
    else:	    
	    abstract_form = AbstractForm()
	
    return render(request, 'submit_abstract.html', {'abstract_form': abstract_form, 'submitted': submitted})
Exemple #5
0
def submit_abstract(request):
    submitted = False

    if request.method == 'POST':
        abstract_form = AbstractForm(request.POST, request.FILES)

        if abstract_form.is_valid():
            abstract = abstract_form.save(commit=False)
            abstract.author = UserProfile.objects.get(user=request.user)
            abstract.delivery_decision = abstract.delivery

            if abstract.tags == "":
                abstract.tags = None
            else:
                abstract.tags = abstract.tags.replace(", ", ",")
                abstract.tags = abstract.tags.replace(",  ", ",")

            try:
                obj = Abstract.objects.latest('id')
                id = obj.id + 1
            except ObjectDoesNotExist:
                id = 0

            abstract.unique_id = 'PVSAT13_%s' % (str(id).zfill(3))

            if 'upload' in request.FILES:
                abstract.upload = request.FILES['upload']

            #Email confirmation to user
            subject = 'Abstract Submission Confirmation: %s' % (
                abstract.unique_id)

            text_content = render_to_string("abs_sub_conf.txt", {
                'abstract': abstract,
                'URL': settings.SITE_URL
            })
            html_content = render_to_string("abs_sub_conf.html", {
                'abstract': abstract,
                'URL': settings.SITE_URL
            })

            email = abstract.author.user.email

            msg1 = EmailMultiAlternatives(subject, text_content, '', [email])
            msg1.attach_alternative(html_content, "text/html")

            #Email confirmation to admin

            subject = 'Abstract %s submitted by %s %s' % (
                abstract.unique_id, abstract.author.user.first_name,
                abstract.author.user.last_name)

            text_content = render_to_string("abs_to_admin.txt", {
                'abstract': abstract,
                'URL': settings.SITE_URL
            })

            msg2 = EmailMultiAlternatives(
                subject, text_content, '',
                [settings.ADMIN_EMAIL, settings.DEFAULT_FROM_EMAIL])

            if settings.EMAIL_STATUS:
                msg1.send()
                msg2.send()

            abstract_form.save()

            return HttpResponseRedirect(reverse('dashboard'))
            submitted = True

        else:
            print abstract_form.errors

    else:
        abstract_form = AbstractForm()

    return render(request, 'submit_abstract.html', {
        'abstract_form': abstract_form,
        'submitted': submitted
    })
Exemple #6
0
def submit_abstract(request):
    submitted = False

    if request.method == 'POST':
        abstract_form = AbstractForm(request.POST, request.FILES)
		
        if abstract_form.is_valid():
            abstract = abstract_form.save(commit=False)
            abstract.author = UserProfile.objects.get(user=request.user)
            abstract.delivery_decision=abstract.delivery

            if abstract.tags == "":
                abstract.tags = None
            else:
                abstract.tags = abstract.tags.replace(", ", ",")
                abstract.tags = abstract.tags.replace(",  ", ",")
                
                

            try:
                obj = Abstract.objects.latest('id')
                id = obj.id + 1
            except ObjectDoesNotExist:
                id = 0

            abstract.unique_id = 'PVSAT13_%s' % (str(id).zfill(3))

            if 'upload' in request.FILES:
			   abstract.upload = request.FILES['upload']

            #Email confirmation to user
            subject = 'Abstract Submission Confirmation: %s' % (abstract.unique_id)

            text_content = render_to_string("abs_sub_conf.txt", {'abstract': abstract, 'URL': settings.SITE_URL})
            html_content = render_to_string("abs_sub_conf.html", {'abstract': abstract, 'URL': settings.SITE_URL})

            email = abstract.author.user.email

            msg1 = EmailMultiAlternatives(subject, text_content, '', [email])
            msg1.attach_alternative(html_content, "text/html")

            #Email confirmation to admin

            subject = 'Abstract %s submitted by %s %s' % (abstract.unique_id, abstract.author.user.first_name, abstract.author.user.last_name)

            text_content = render_to_string("abs_to_admin.txt", {'abstract': abstract, 'URL': settings.SITE_URL})

            msg2 = EmailMultiAlternatives(subject, text_content, '', [settings.ADMIN_EMAIL, settings.DEFAULT_FROM_EMAIL])

            if settings.EMAIL_STATUS:
                msg1.send()
                msg2.send()
                

            abstract_form.save()

            return HttpResponseRedirect(reverse('dashboard'))
            submitted = True



        else:
			print abstract_form.errors
    
    else:	    
	    abstract_form = AbstractForm()
	
    return render(request, 'submit_abstract.html', {'abstract_form': abstract_form, 'submitted': submitted})