uploadfiles
This commit is contained in:
parent
54cbda55e0
commit
2b842a7238
@ -16,7 +16,7 @@ Including another URLconf
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from alkatorapi.views import register, results, photos, payment_result, payment_state, invoice
|
||||
from alkatorapi.views import register, results, photos, payment_result, payment_state, invoice, upload_files
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
@ -26,4 +26,5 @@ urlpatterns = [
|
||||
path('api/payment_result', payment_result),
|
||||
path('api/payment_state', payment_state),
|
||||
path('api/invoice', invoice),
|
||||
path('api/upload_files', upload_files)
|
||||
]
|
||||
|
@ -196,6 +196,17 @@ def photos(request):
|
||||
return HttpResponse(json.dumps(rtn), content_type='application/json')
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
def upload_files(request):
|
||||
for name, file request.FILES.items():
|
||||
print(name)
|
||||
rand = random.randint(9999999999999)
|
||||
random_name = f'photos/uploads/{rand}.jpg'
|
||||
with open(random_name, "wb+") as destination:
|
||||
for chunk in f.chunks():
|
||||
destination.write(chunk)
|
||||
|
||||
|
||||
@staff_member_required
|
||||
def invoice(request):
|
||||
user = User.objects.get(invoice_id=request.GET['invoice_id'])
|
||||
|
@ -57,8 +57,9 @@ class Main extends Component {
|
||||
onSubmit(event){
|
||||
event.preventDefault();
|
||||
let form = document.getElementById("form");
|
||||
let api_endpoint = form.action;
|
||||
let formData = new FormData(form);
|
||||
fetch(addr_prefix + "/api/register", {
|
||||
fetch(addr_prefix + api_endpoint, {
|
||||
method:"POST",
|
||||
body: formData,
|
||||
}).then(resp => resp.json()).then(json => {
|
||||
@ -72,7 +73,9 @@ class Main extends Component {
|
||||
text: json.success,
|
||||
status: "success",
|
||||
})
|
||||
window.open(json.redirect ,"_self")
|
||||
if (json.redirect){
|
||||
window.open(json.redirect ,"_self")
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -122,12 +125,30 @@ class Main extends Component {
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#gallery">Galerie</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#upload_files">Nahrát vlastní fotky/videa</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#payment">Platba</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
{this.state.status == "success" &&
|
||||
<div class="absolute container-fluid alert alert-success">
|
||||
{this.state.text}
|
||||
</div>}
|
||||
{this.state.status == "failed" &&
|
||||
<div class="absolute container-fluid alert alert-danger">
|
||||
{this.state.text}
|
||||
</div>}
|
||||
{this.state.page == "#upload_files" &&
|
||||
<div>
|
||||
<form id="form" action="/api/upload_files" class="container" onSubmit={(e) => this.onSubmit(e)}>
|
||||
<label>Zvolte soubory <input type="file" accept=".jpg,.png,.webp,.webm,.avi,.mkv,.mp4" multiple="true" /></label>
|
||||
<button type="submit" class="btn btn-primary">Nahrát</button>
|
||||
</form>
|
||||
</div>}
|
||||
{this.state.page == "#payment" &&
|
||||
<div class="container text">
|
||||
Platební bránu poskytuje firma <a href="https://www.comgate.cz/cz/platebni-brana">Comgate, a.s</a>. Platit je možné pomocí <a href="https://help.comgate.cz/v1/docs/cs/platby-kartou">platební karty</a> nebo <a href="https://help.comgate.cz/docs/bankovni-prevody">bankovním převodem</a>. Podrobnosti a přesný postup platby včetně animací najdete v odkazech.<br />
|
||||
@ -144,14 +165,6 @@ class Main extends Component {
|
||||
}
|
||||
{this.state.page == "" &&
|
||||
<div>
|
||||
{this.state.status == "success" &&
|
||||
<div class="absolute container-fluid alert alert-success">
|
||||
{this.state.text}
|
||||
</div>}
|
||||
{this.state.status == "failed" &&
|
||||
<div class="absolute container-fluid alert alert-danger">
|
||||
{this.state.text}
|
||||
</div>}
|
||||
{this.state.faq &&
|
||||
<div class="shadow"></div>}
|
||||
{this.state.faq &&
|
||||
@ -286,7 +299,7 @@ class Main extends Component {
|
||||
<div class="container text text-center">
|
||||
<h2>Stále nevíš, jestli se zúčastníš? Přečti si náš <button type="button" class="btn btn-warning" onClick={(e) => this.togglefaq()}>FAQ</button></h2>
|
||||
</div>
|
||||
<form id="form" class="container" onSubmit={(e) => this.onSubmit(e)}>
|
||||
<form id="form" class="container" action="/api/register" onSubmit={(e) => this.onSubmit(e)}>
|
||||
<h1>Registrace</h1>
|
||||
<div class="mb-3">
|
||||
<label for="first_name" class="form-label">Jméno</label>
|
||||
|
0
photos/.gitkeep → photos/1/.gitkeep
Normal file → Executable file
0
photos/.gitkeep → photos/1/.gitkeep
Normal file → Executable file
0
photos/2/.gitkeep
Executable file
0
photos/2/.gitkeep
Executable file
0
photos/uploads/.gitkeep
Executable file
0
photos/uploads/.gitkeep
Executable file
@ -1,7 +1,7 @@
|
||||
import glob
|
||||
import PIL.Image
|
||||
|
||||
photos = glob.glob('photos/*.jpg')
|
||||
photos = glob.glob('photos/2/*.jpg')
|
||||
|
||||
for image in photos:
|
||||
print(image)
|
||||
|
Loading…
x
Reference in New Issue
Block a user