Merge branch 'beta'
This commit is contained in:
commit
1ab5174c40
@ -8,8 +8,8 @@ ALKATOR_CHOICES = (
|
||||
)
|
||||
|
||||
ALKATOR_CLASSES = (
|
||||
(2, "Podzim 2024"),
|
||||
(1, "Jaro 2024"),
|
||||
(1, "Jaro 2024 Sobkovice"),
|
||||
(2, "Podzim 2024 Studené"),
|
||||
)
|
||||
|
||||
ALKATOR_CHOICES_DICT = {
|
||||
|
@ -11,6 +11,7 @@ import json
|
||||
import glob
|
||||
import PIL.Image
|
||||
import random
|
||||
from collections import OrderedDict
|
||||
|
||||
from .models import User, ALKATOR_CHOICES_DICT, ALKATOR_CLASSES
|
||||
from alkator.settings import COMGATE_MERCHANT, COMGATE_SECRET, COMGATE_TEST
|
||||
@ -194,16 +195,22 @@ def results(request):
|
||||
def photos(request):
|
||||
rtn = []
|
||||
for (i, name) in ALKATOR_CLASSES:
|
||||
photos = {}
|
||||
rtn.append(photos)
|
||||
photos['name'] = name
|
||||
photos['index'] = i
|
||||
photos['photos'] = []
|
||||
files = glob.glob(f"photos/{i}/*.jpg")
|
||||
random.shuffle(files)
|
||||
for file in files:
|
||||
img = PIL.Image.open(file)
|
||||
rtn.append({
|
||||
photos['photos'].append({
|
||||
'original': '/' + file.replace(".jpg", ".webp"),
|
||||
'thumbnail': '/' + file.replace(f'photos/{i}/', f'photos/{i}/thumbnail/').replace(".jpg", ".webp"),
|
||||
'original_width': img.width,
|
||||
'original_height': img.height,
|
||||
})
|
||||
|
||||
return HttpResponse(json.dumps(rtn), content_type='application/json')
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@ class Main extends Component {
|
||||
status: "",
|
||||
faq: false,
|
||||
results: [],
|
||||
gallery_open: undefined,
|
||||
page: window.location.hash,
|
||||
photos: [],
|
||||
photoIsOpen: false,
|
||||
@ -46,6 +47,9 @@ class Main extends Component {
|
||||
}
|
||||
window.addEventListener("hashchange", (e) => {this.onHashChange(e)})
|
||||
}
|
||||
openGallery = (i) => {
|
||||
this.setState({gallery_open: i})
|
||||
}
|
||||
closePhoto = () => {
|
||||
this.setState(state => ({ photoIsOpen: false }))
|
||||
}
|
||||
@ -56,7 +60,7 @@ class Main extends Component {
|
||||
})
|
||||
}
|
||||
onHashChange(event){
|
||||
this.setState({page: window.location.hash})
|
||||
this.setState({page: window.location.hash, gallery_open: undefined})
|
||||
}
|
||||
handleChangeFiles(event) {
|
||||
this.setState({files: [...event.target.files]})
|
||||
@ -105,17 +109,19 @@ class Main extends Component {
|
||||
}
|
||||
render(){
|
||||
let photos_gallery = [];
|
||||
let photos_carousel = []
|
||||
for (const photo of this.state.photos){
|
||||
photos_gallery.push({
|
||||
src: photo.thumbnail,
|
||||
width: photo.original_width,
|
||||
height: photo.original_height,
|
||||
})
|
||||
photos_carousel.push({
|
||||
original: photo.original
|
||||
})
|
||||
};
|
||||
let photos_carousel = [];
|
||||
if(this.state.gallery_open !== undefined){
|
||||
for (const photo of this.state.photos[this.state.gallery_open].photos){
|
||||
photos_gallery.push({
|
||||
src: photo.thumbnail,
|
||||
width: photo.original_width,
|
||||
height: photo.original_height,
|
||||
})
|
||||
photos_carousel.push({
|
||||
original: photo.original
|
||||
})
|
||||
};
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<ModalGateway>
|
||||
@ -176,8 +182,21 @@ class Main extends Component {
|
||||
</div>
|
||||
}
|
||||
{this.state.page == "#gallery" &&
|
||||
<div class="container" style={{display: "flex"}}>
|
||||
{this.state.photos.map((photos, index) =>
|
||||
<div class="card" style={{"width": "18rem", margin: "10px"}}>
|
||||
<img src={'/photos/plakat_' + photos.index + '.jpg'} class="card-img-top" />
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{photos.name}</h5>
|
||||
<a href="#gallery" class="btn btn-primary" onClick={(e) => {e.preventDefault(); this.openGallery(index)}}>Otevřít galerii</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
{this.state.page == "#gallery" && this.state.gallery_open !== undefined &&
|
||||
<div class="container">
|
||||
<Gallery photos={photos_gallery} onClick={this.openPhoto}/>
|
||||
<Gallery style={{}} photos={photos_gallery} onClick={this.openPhoto}/>
|
||||
</div>
|
||||
}
|
||||
{this.state.page == "" &&
|
||||
@ -377,7 +396,8 @@ class Main extends Component {
|
||||
Číslo účtu: 131-2219860207/0100<br />
|
||||
E-mail: info@alkator.cz<br />
|
||||
Tel: +420 728 018 088<br />
|
||||
<img src="/public/footer.png" style={{"width":"100%","height":"auto"}} />
|
||||
<img src="/public/footer.png" style={{"width":"100%","height":"auto"}} /><br/>
|
||||
© Alkátor team 2024
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
BIN
photos/plakat_2.jpg
Normal file
BIN
photos/plakat_2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 115 KiB |
Loading…
x
Reference in New Issue
Block a user