Merge branch 'beta'
This commit is contained in:
commit
9820aa10be
@ -16,7 +16,7 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
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 = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
@ -26,4 +26,5 @@ urlpatterns = [
|
|||||||
path('api/payment_result', payment_result),
|
path('api/payment_result', payment_result),
|
||||||
path('api/payment_state', payment_state),
|
path('api/payment_state', payment_state),
|
||||||
path('api/invoice', invoice),
|
path('api/invoice', invoice),
|
||||||
|
path('api/upload_files', upload_files)
|
||||||
]
|
]
|
||||||
|
@ -207,6 +207,18 @@ def photos(request):
|
|||||||
return HttpResponse(json.dumps(rtn), content_type='application/json')
|
return HttpResponse(json.dumps(rtn), content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
def upload_files(request):
|
||||||
|
for name, file in request.FILES.items():
|
||||||
|
print(name)
|
||||||
|
rand = random.randint(0, 99999)
|
||||||
|
random_name = f'photos/uploads/{rand}_{file.name}'
|
||||||
|
with open(random_name, "wb+") as destination:
|
||||||
|
for chunk in file.chunks():
|
||||||
|
destination.write(chunk)
|
||||||
|
return HttpResponse('{"success":"Úspěšně nahráno! Počkejte až dojde ke schválení nahraných souborů."}', content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
@staff_member_required
|
@staff_member_required
|
||||||
def invoice(request):
|
def invoice(request):
|
||||||
user = User.objects.get(invoice_id=request.GET['invoice_id'])
|
user = User.objects.get(invoice_id=request.GET['invoice_id'])
|
||||||
|
@ -15,6 +15,7 @@ class Main extends Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
files: [],
|
||||||
text: "",
|
text: "",
|
||||||
status: "",
|
status: "",
|
||||||
faq: false,
|
faq: false,
|
||||||
@ -55,15 +56,19 @@ class Main extends Component {
|
|||||||
onHashChange(event){
|
onHashChange(event){
|
||||||
this.setState({page: window.location.hash})
|
this.setState({page: window.location.hash})
|
||||||
}
|
}
|
||||||
|
handleChangeFiles(event) {
|
||||||
|
this.setState({files: [...event.target.files]})
|
||||||
|
}
|
||||||
onSubmit(event){
|
onSubmit(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let form = document.getElementById("form");
|
let form = document.getElementById("form");
|
||||||
|
let api_endpoint = form.action;
|
||||||
let formData = new FormData(form);
|
let formData = new FormData(form);
|
||||||
if(this.state.progress){
|
if(this.state.progress){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({progress: true})
|
this.setState({progress: true})
|
||||||
fetch(addr_prefix + "/api/register", {
|
fetch(addr_prefix + api_endpoint, {
|
||||||
method:"POST",
|
method:"POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
}).then(resp => resp.json()).then(json => {
|
}).then(resp => resp.json()).then(json => {
|
||||||
@ -78,7 +83,9 @@ class Main extends Component {
|
|||||||
text: json.success,
|
text: json.success,
|
||||||
status: "success",
|
status: "success",
|
||||||
})
|
})
|
||||||
window.open(json.redirect ,"_self")
|
if (json.redirect){
|
||||||
|
window.open(json.redirect ,"_self")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -128,12 +135,30 @@ class Main extends Component {
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#gallery">Galerie</a>
|
<a class="nav-link" href="#gallery">Galerie</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="#upload_files">Nahrát vlastní fotky/videa</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#payment">Platba</a>
|
<a class="nav-link" href="#payment">Platba</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</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" name="files" accept=".jpg,.png,.webp,.webm,.avi,.mkv,.mp4" multiple={true} onChange={(e)=> this.handleChangeFiles.bind(this)(e)}/></label>
|
||||||
|
<button type="submit" class="btn btn-primary">Nahrát</button>
|
||||||
|
</form>
|
||||||
|
</div>}
|
||||||
{this.state.page == "#payment" &&
|
{this.state.page == "#payment" &&
|
||||||
<div class="container text">
|
<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 />
|
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 />
|
||||||
@ -150,14 +175,6 @@ class Main extends Component {
|
|||||||
}
|
}
|
||||||
{this.state.page == "" &&
|
{this.state.page == "" &&
|
||||||
<div>
|
<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 &&
|
{this.state.faq &&
|
||||||
<div class="shadow"></div>}
|
<div class="shadow"></div>}
|
||||||
{this.state.faq &&
|
{this.state.faq &&
|
||||||
@ -261,7 +278,7 @@ class Main extends Component {
|
|||||||
<p>Sportem ku chlastu!</p>
|
<p>Sportem ku chlastu!</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-6">
|
<div class="col-xl-6">
|
||||||
<h1 class="text" >Výsledky 2. ročníku (Podzim 2024)</h1>
|
<h1 class="text">Výsledky 1. ročníku</h1>
|
||||||
{this.state.results &&
|
{this.state.results &&
|
||||||
<table class="table results">
|
<table class="table results">
|
||||||
<thead>
|
<thead>
|
||||||
@ -296,7 +313,7 @@ class Main extends Component {
|
|||||||
<h1>Kapacita je aktuálně naplněna, budem se těšit u dalšího ročníku.</h1>
|
<h1>Kapacita je aktuálně naplněna, budem se těšit u dalšího ročníku.</h1>
|
||||||
</div>
|
</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>
|
<h1>Registrace</h1>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="first_name" class="form-label">Jméno</label>
|
<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 glob
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
|
|
||||||
photos = glob.glob('photos/*.jpg')
|
photos = glob.glob('photos/2/*.jpg')
|
||||||
|
|
||||||
for image in photos:
|
for image in photos:
|
||||||
print(image)
|
print(image)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user