Commit b1b65d13 authored by Jomaro Rodrigues's avatar Jomaro Rodrigues
Browse files

Merge branch 'master' into patch-1

parents 2ed0401f ff6aa6bb
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = 'uploads'
{% extends 'base.html' %}
{% block content %}
<ul>
<li>
<a href="{% url 'uploads:simple' %}">Simple Upload</a>
</li>
<li>
<a href="{% url 'uploads:model_form' %}">Model Form Upload</a>
</li>
</ul>
<p>Uploaded files:</p>
<ul>
{% for obj in documents %}
<li>
<a href="{{ obj.document.url }}">{{ obj.document.name }}</a>
<small>(Uploaded at: {{ obj.uploaded_at }})</small>
</li>
{% endfor %}
</ul>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer id ante porta, mattis neque in, aliquet eros. Mauris a dolor at nisl posuere fermentum facilisis sed orci. Curabitur pretium nibh arcu, vitae fermentum lacus malesuada sit amet. Fusce porta sapien ac elit feugiat semper. Donec eu erat ultricies, dictum ligula et, tempor est. Morbi at convallis nisl. Quisque eget posuere justo. Fusce pellentesque pharetra dolor, in viverra lorem commodo non. Nunc vel odio euismod, commodo dolor a, euismod leo. Praesent facilisis lectus eget sem aliquam accumsan. Praesent iaculis neque vel tristique tristique. </p>
<p>Cras ac posuere augue. Nulla facilisis semper sodales. Fusce dapibus magna eu ligula ullamcorper, ac tincidunt leo congue. Nulla viverra lacinia urna, in fermentum ligula scelerisque et. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis ullamcorper tellus vel sollicitudin fermentum. Nunc at sem in ante iaculis fermentum id a ante. Cras consequat eleifend elit eget tristique. Maecenas iaculis mauris at tempus bibendum. </p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block content %}
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Upload</button>
</form>
<p><a href="{% url 'uploads:home' %}">Return to home</a></p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="historico">
<input type="file" name="matricula">
<button type="submit">Upload</button>
</form>
{% if uploaded_file_url %}
<p>File uploaded at: <a href="{{ uploaded_file_url }}">{{ uploaded_file_url }}</a></p>
{% endif %}
<p><a href="{% url 'uploads:home' %}">Return to home</a></p>
{% endblock %}
{% extends 'base.html' %}
{% load static %}
{% block content %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="custom-file">
<input type="file" class="custom-file-input" id="aslsndf_hist" name="historico">
<label class="custom-file-label" for="aslsndf_hist">Histórico</label>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="aslsndf_matr" name="matricula">
<label class="custom-file-label" for="aslsndf_matr">Matrícula</label>
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
</form>
{% endblock %}
......@@ -6,9 +6,7 @@ from uploads import views
urlpatterns = [
url(r'^$', views.home, name='home'),
url(r'^simple/$', views.simple_upload, name='simple'),
url(r'^form/$', views.model_form_upload, name='model_form'),
url(r'^$', views.upload, name='upload'),
]
if settings.DEBUG:
......
from django.shortcuts import render, redirect
from django.core.files.storage import FileSystemStorage
from uploads.models import Submission
from uploads.core.models import Document
from uploads.core.forms import DocumentForm
def home(request):
documents = Document.objects.all()
return render(request, 'uploads/home.html', {'documents': documents})
from django.contrib import messages
from uploads.models import Submission
def simple_upload(request):
def upload(request):
if request.method == 'POST' and request.FILES['historico'] and request.FILES['matricula']:
submission = Submission.objects.create(author=request.user)
......@@ -30,17 +22,8 @@ def simple_upload(request):
submission.save()
return render(request, 'core/simple_upload.html')
messages.success(request, 'Sua submissão foi realizada com sucesso, por favor aguarde o processamento')
return redirect('dashboard')
def model_form_upload(request):
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect('uploads:home')
else:
form = DocumentForm()
return render(request, 'uploads/model_form_upload.html', {
'form': form
})
return render(request, 'uploads/upload.html')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment