Unified indentation using 4 spacec according to PEP8.
This commit is contained in:
parent
2b3fa6f216
commit
985ab2ed75
@ -42,7 +42,7 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'easy_thumbnails',
|
'easy_thumbnails',
|
||||||
'widget_tweaks',
|
'widget_tweaks',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
@ -141,7 +141,7 @@ LOGOUT_REDIRECT_URL = 'home'
|
|||||||
THUMBNAIL_ALIASES = {
|
THUMBNAIL_ALIASES = {
|
||||||
'': {
|
'': {
|
||||||
'thumbnail': {'size': (300, 300), 'crop': False},
|
'thumbnail': {'size': (300, 300), 'crop': False},
|
||||||
'hero': {'size': (700, 700), 'crop': False},
|
'hero': {'size': (700, 700), 'crop': False},
|
||||||
'large': {'size': (1920, 1920), 'crop': False},
|
'large': {'size': (1920, 1920), 'crop': False},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -8,43 +8,43 @@ from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
|||||||
from .models import Explorer, Place, PlaceImage, Voucher
|
from .models import Explorer, Place, PlaceImage, Voucher
|
||||||
|
|
||||||
class ExplorerCreationForm(UserCreationForm):
|
class ExplorerCreationForm(UserCreationForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Explorer
|
model = Explorer
|
||||||
fields = ('username', 'email')
|
fields = ('username', 'email')
|
||||||
voucher = forms.CharField(max_length=10, help_text='The Voucher you got from an administrator')
|
voucher = forms.CharField(max_length=10, help_text='The Voucher you got from an administrator')
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
super().is_valid()
|
super().is_valid()
|
||||||
sumitted_voucher = self.cleaned_data.get('voucher')
|
sumitted_voucher = self.cleaned_data.get('voucher')
|
||||||
try:
|
try:
|
||||||
fetched_voucher = Voucher.objects.get(code=sumitted_voucher)
|
fetched_voucher = Voucher.objects.get(code=sumitted_voucher)
|
||||||
except Voucher.DoesNotExist:
|
except Voucher.DoesNotExist:
|
||||||
self.add_error('voucher', 'Invalid voucher')
|
self.add_error('voucher', 'Invalid voucher')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
fetched_voucher.delete()
|
fetched_voucher.delete()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class ExplorerChangeForm(UserChangeForm):
|
class ExplorerChangeForm(UserChangeForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Explorer
|
model = Explorer
|
||||||
fields = ('username', 'email')
|
fields = ('username', 'email')
|
||||||
|
|
||||||
class PlaceForm(forms.ModelForm):
|
class PlaceForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Place
|
model = Place
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
exclude = ['submitted_by']
|
exclude = ['submitted_by']
|
||||||
|
|
||||||
class PlaceImageCreateForm(forms.ModelForm):
|
class PlaceImageCreateForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PlaceImage
|
model = PlaceImage
|
||||||
fields = ['filename']
|
fields = ['filename']
|
||||||
widgets = {
|
widgets = {
|
||||||
'filename': forms.ClearableFileInput(attrs={'multiple': True})
|
'filename': forms.ClearableFileInput(attrs={'multiple': True})
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.fields['filename'].required = False
|
self.fields['filename'].required = False
|
||||||
|
@ -14,115 +14,115 @@ from easy_thumbnails.fields import ThumbnailerImageField
|
|||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
class Explorer(AbstractUser):
|
class Explorer(AbstractUser):
|
||||||
"""
|
"""
|
||||||
Custom user model
|
Custom user model
|
||||||
Addtional fields wbd
|
Addtional fields wbd
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.username
|
return self.username
|
||||||
|
|
||||||
class Voucher(models.Model):
|
class Voucher(models.Model):
|
||||||
"""
|
"""
|
||||||
Vouchers are authorization tokens to allow the registration of new users.
|
Vouchers are authorization tokens to allow the registration of new users.
|
||||||
A voucher has a code, a creation and a deletion date, which are all positional.
|
A voucher has a code, a creation and a deletion date, which are all positional.
|
||||||
Creation date is being set automatically during voucher creation.
|
Creation date is being set automatically during voucher creation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
code = models.CharField(unique=True, max_length=10)
|
code = models.CharField(unique=True, max_length=10)
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
expires = models.DateField()
|
expires = models.DateField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Voucher " + str(self.pk)
|
return "Voucher " + str(self.pk)
|
||||||
|
|
||||||
class Place (models.Model):
|
class Place (models.Model):
|
||||||
"""
|
"""
|
||||||
Place defines a lost place (location, name, description etc.).
|
Place defines a lost place (location, name, description etc.).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
submitted_when = models.DateTimeField(auto_now_add=True, null=True)
|
||||||
submitted_by = models.ForeignKey(
|
submitted_by = models.ForeignKey(
|
||||||
Explorer,
|
Explorer,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name='places'
|
related_name='places'
|
||||||
)
|
)
|
||||||
location = models.CharField(max_length=50)
|
location = models.CharField(max_length=50)
|
||||||
latitude = models.FloatField()
|
latitude = models.FloatField()
|
||||||
longitude = models.FloatField()
|
longitude = models.FloatField()
|
||||||
description = models.TextField()
|
description = models.TextField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def generate_image_upload_path(instance, filename):
|
def generate_image_upload_path(instance, filename):
|
||||||
"""
|
"""
|
||||||
Callback for generating path for uploaded images.
|
Callback for generating path for uploaded images.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1]
|
return 'places/' + str(uuid.uuid4())+'.'+filename.split('.')[-1]
|
||||||
|
|
||||||
class PlaceImage (models.Model):
|
class PlaceImage (models.Model):
|
||||||
"""
|
"""
|
||||||
PlaceImage defines an image file object that points to a file in uploads/.
|
PlaceImage defines an image file object that points to a file in uploads/.
|
||||||
Intermediate image sizes are generated as defined in SIZES.
|
Intermediate image sizes are generated as defined in SIZES.
|
||||||
PlaceImage references a Place to which it belongs.
|
PlaceImage references a Place to which it belongs.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
description = models.TextField(blank=True)
|
description = models.TextField(blank=True)
|
||||||
filename = ThumbnailerImageField(upload_to=generate_image_upload_path)
|
filename = ThumbnailerImageField(upload_to=generate_image_upload_path)
|
||||||
place = models.ForeignKey(
|
place = models.ForeignKey(
|
||||||
Place,
|
Place,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
related_name='images'
|
related_name='images'
|
||||||
)
|
)
|
||||||
submitted_by = models.ForeignKey(
|
submitted_by = models.ForeignKey(
|
||||||
Explorer,
|
Explorer,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name='images'
|
related_name='images'
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""
|
"""
|
||||||
Returning the name of the corresponding place + id
|
Returning the name of the corresponding place + id
|
||||||
of this image as textual represntation of this instance
|
of this image as textual represntation of this instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return ' '.join([self.place.name, str(self.pk)])
|
return ' '.join([self.place.name, str(self.pk)])
|
||||||
|
|
||||||
# These two auto-delete files from filesystem when they are unneeded:
|
# These two auto-delete files from filesystem when they are unneeded:
|
||||||
|
|
||||||
@receiver(models.signals.post_delete, sender=PlaceImage)
|
@receiver(models.signals.post_delete, sender=PlaceImage)
|
||||||
def auto_delete_file_on_delete(sender, instance, **kwargs):
|
def auto_delete_file_on_delete(sender, instance, **kwargs):
|
||||||
"""
|
"""
|
||||||
Deletes file from filesystem
|
Deletes file from filesystem
|
||||||
when corresponding `PlaceImage` object is deleted.
|
when corresponding `PlaceImage` object is deleted.
|
||||||
"""
|
"""
|
||||||
if instance.filename:
|
if instance.filename:
|
||||||
if os.path.isfile(instance.filename.path):
|
if os.path.isfile(instance.filename.path):
|
||||||
os.remove(instance.filename.path)
|
os.remove(instance.filename.path)
|
||||||
|
|
||||||
@receiver(models.signals.pre_save, sender=PlaceImage)
|
@receiver(models.signals.pre_save, sender=PlaceImage)
|
||||||
def auto_delete_file_on_change(sender, instance, **kwargs):
|
def auto_delete_file_on_change(sender, instance, **kwargs):
|
||||||
"""
|
"""
|
||||||
Deletes old file from filesystem
|
Deletes old file from filesystem
|
||||||
when corresponding `PlaceImage` object is updated
|
when corresponding `PlaceImage` object is updated
|
||||||
with new file.
|
with new file.
|
||||||
"""
|
"""
|
||||||
if not instance.pk:
|
if not instance.pk:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
old_file = PlaceImage.objects.get(pk=instance.pk).filename
|
old_file = PlaceImage.objects.get(pk=instance.pk).filename
|
||||||
except PlaceImage.DoesNotExist:
|
except PlaceImage.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
new_file = instance.filename
|
new_file = instance.filename
|
||||||
if not old_file == new_file:
|
if not old_file == new_file:
|
||||||
if os.path.isfile(old_file.path):
|
if os.path.isfile(old_file.path):
|
||||||
os.remove(old_file.path)
|
os.remove(old_file.path)
|
||||||
|
@ -5,43 +5,43 @@
|
|||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<form class="LP-Form" method="POST" enctype="multipart/form-data">
|
<form class="LP-Form" method="POST" enctype="multipart/form-data">
|
||||||
<fieldset class="LP-Form__Fieldset">
|
<fieldset class="LP-Form__Fieldset">
|
||||||
<legend class="LP-Form__Legend">Place erstellen</legend>
|
<legend class="LP-Form__Legend">Place erstellen</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=place_form.name %}
|
{% include 'partials/form/inputField.html' with field=place_form.name %}
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=place_form.location %}
|
{% include 'partials/form/inputField.html' with field=place_form.location %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=place_form.latitude %}
|
{% include 'partials/form/inputField.html' with field=place_form.latitude %}
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=place_form.longitude %}
|
{% include 'partials/form/inputField.html' with field=place_form.longitude %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=place_form.description %}
|
{% include 'partials/form/inputField.html' with field=place_form.description %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=place_image_form.filename %}
|
{% include 'partials/form/inputField.html' with field=place_image_form.filename %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<input type="submit" class="LP-Button" value="Abschicken"/>
|
<input type="submit" class="LP-Button" value="Abschicken"/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<div class="LP-PlaceGrid">
|
<div class="LP-PlaceGrid">
|
||||||
<h1 class="LP-Headline LP-Headline">Explore the latest locations</h1>
|
<h1 class="LP-Headline LP-Headline">Explore the latest locations</h1>
|
||||||
<ul class="LP-PlaceGrid__Grid">
|
<ul class="LP-PlaceGrid__Grid">
|
||||||
{% for place in place_list %}
|
{% for place in place_list %}
|
||||||
<li class="LP-PlaceGrid__Item">
|
<li class="LP-PlaceGrid__Item">
|
||||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
<article class="LP-PlaceTeaser">
|
<article class="LP-PlaceTeaser">
|
||||||
@ -35,10 +35,10 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
<div class="LP-Input {% if field.errors %} LP-Input--error {% endif %}">
|
<div class="LP-Input {% if field.errors %} LP-Input--error {% endif %}">
|
||||||
<label for="{{field.id_for_label}}" class="LP-Input__Label">{{field.label}}</label>
|
<label for="{{field.id_for_label}}" class="LP-Input__Label">{{field.label}}</label>
|
||||||
{% render_field field class="LP-Input__Field"%}
|
{% render_field field class="LP-Input__Field"%}
|
||||||
|
|
||||||
<span class="LP-Input__Message">
|
<span class="LP-Input__Message">
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
{% for error in field.errors%}
|
{% for error in field.errors%}
|
||||||
{{error}}
|
{{error}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% elif field.help_text%}
|
{% elif field.help_text%}
|
||||||
{{ field.help_text }}
|
{{ field.help_text }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
@ -11,8 +11,8 @@
|
|||||||
<article class="LP-PlaceOverview">
|
<article class="LP-PlaceOverview">
|
||||||
<div class="LP-PlaceOverview__Info">
|
<div class="LP-PlaceOverview__Info">
|
||||||
<div class="LP-PlaceOveriew__Image">
|
<div class="LP-PlaceOveriew__Image">
|
||||||
<img src="{{ place.images.first.filename.hero.url }}" class="LP-Image" />
|
<img src="{{ place.images.first.filename.hero.url }}" class="LP-Image" />
|
||||||
</div>
|
</div>
|
||||||
<article class="LP-PlaceOverView__Description">
|
<article class="LP-PlaceOverView__Description">
|
||||||
<div class="LP-TextSection">
|
<div class="LP-TextSection">
|
||||||
<h1 class="LP-Headline LP-Headline">{{place.name}}</h1>
|
<h1 class="LP-Headline LP-Headline">{{place.name}}</h1>
|
||||||
@ -26,26 +26,26 @@
|
|||||||
<div class="LP-Content">
|
<div class="LP-Content">
|
||||||
<div class="LP-TagList">
|
<div class="LP-TagList">
|
||||||
<ul class="LP-TagList__List">
|
<ul class="LP-TagList__List">
|
||||||
<li class="LP-TagList__Item">
|
<li class="LP-TagList__Item">
|
||||||
<div class="LP-Tag">
|
<div class="LP-Tag">
|
||||||
<p class="LP-Paragraph LP-Paragraph">Kamera</p>
|
<p class="LP-Paragraph LP-Paragraph">Kamera</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="LP-TagList__Item">
|
<li class="LP-TagList__Item">
|
||||||
<div class="LP-Tag">
|
<div class="LP-Tag">
|
||||||
<p class="LP-Paragraph LP-Paragraph">Wachhund</p>
|
<p class="LP-Paragraph LP-Paragraph">Wachhund</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="LP-TagList__Item">
|
<li class="LP-TagList__Item">
|
||||||
<div class="LP-Tag">
|
<div class="LP-Tag">
|
||||||
<p class="LP-Paragraph LP-Paragraph">Zaun</p>
|
<p class="LP-Paragraph LP-Paragraph">Zaun</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="LP-TagList__Item">
|
<li class="LP-TagList__Item">
|
||||||
<div class="LP-Tag">
|
<div class="LP-Tag">
|
||||||
<p class="LP-Paragraph LP-Paragraph">Security</p>
|
<p class="LP-Paragraph LP-Paragraph">Security</p>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -57,22 +57,22 @@
|
|||||||
<div class="LP-Content">
|
<div class="LP-Content">
|
||||||
<ul class="LP-LinkList__List">
|
<ul class="LP-LinkList__List">
|
||||||
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.google.com/maps?q={{place.latitude}},{{place.longitude}}" class="LP-Link"><span class="LP-Text">Google Maps</span></a></li>
|
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.google.com/maps?q={{place.latitude}},{{place.longitude}}" class="LP-Link"><span class="LP-Text">Google Maps</span></a></li>
|
||||||
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.tim-online.nrw.de/tim-online2/?center={{place.latitude}},{{place.longitude}}&icon=true&bg=dop" class="LP-Link"><span class="LP-Text">TIM Online</span></a></li>
|
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.tim-online.nrw.de/tim-online2/?center={{place.latitude}},{{place.longitude}}&icon=true&bg=dop" class="LP-Link"><span class="LP-Text">TIM Online</span></a></li>
|
||||||
<li class="LP-LinkList__Item"><a target="_blank" href="http://www.openstreetmap.org/?mlat={{place.latitude}}&mlon={{place.longitude}}&zoom=16" class="LP-Link"><span class="LP-Text">OSM</span></a></li>
|
<li class="LP-LinkList__Item"><a target="_blank" href="http://www.openstreetmap.org/?mlat={{place.latitude}}&mlon={{place.longitude}}&zoom=16" class="LP-Link"><span class="LP-Text">OSM</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<article class="LP-Section">
|
<article class="LP-Section">
|
||||||
<h1 class="LP-Headline LP-Headline">Bilder</h1>
|
<h1 class="LP-Headline LP-Headline">Bilder</h1>
|
||||||
<div class="LP-Content__Wrapper">
|
<div class="LP-Content__Wrapper">
|
||||||
<div class=" LP-Content">
|
<div class=" LP-Content">
|
||||||
<ul class="LP-PlaceOverView__ImageList">
|
<ul class="LP-PlaceOverView__ImageList">
|
||||||
{% for place_image in place.images.all %}
|
{% for place_image in place.images.all %}
|
||||||
<li class="LP-PlaceOverView__ImageItem">
|
<li class="LP-PlaceOverView__ImageItem">
|
||||||
<a href="{{ place_image.filename.large.url }}" class="LP-Link"><img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}"></a>
|
<a href="{{ place_image.filename.large.url }}" class="LP-Link"><img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}"></a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,43 +5,43 @@
|
|||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<form class="LP-Form" method="POST" enctype="multipart/form-data">
|
<form class="LP-Form" method="POST" enctype="multipart/form-data">
|
||||||
<fieldset class="LP-Form__Fieldset">
|
<fieldset class="LP-Form__Fieldset">
|
||||||
<legend class="LP-Form__Legend">Place aktualisieren</legend>
|
<legend class="LP-Form__Legend">Place aktualisieren</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.name %}
|
{% include 'partials/form/inputField.html' with field=form.name %}
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.location %}
|
{% include 'partials/form/inputField.html' with field=form.location %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.latitude %}
|
{% include 'partials/form/inputField.html' with field=form.latitude %}
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.longitude %}
|
{% include 'partials/form/inputField.html' with field=form.longitude %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.description %}
|
{% include 'partials/form/inputField.html' with field=form.description %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.filename %}
|
{% include 'partials/form/inputField.html' with field=form.filename %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<input type="submit" class="LP-Button" value="Abschicken"/>
|
<input type="submit" class="LP-Button" value="Abschicken"/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from .views import (
|
from .views import (
|
||||||
hello_world,
|
hello_world,
|
||||||
HomeView,
|
HomeView,
|
||||||
place_detail_view,
|
place_detail_view,
|
||||||
place_list_view,
|
place_list_view,
|
||||||
SignUpView,
|
SignUpView,
|
||||||
@ -11,7 +11,7 @@ from .views import (
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('hello_world/', hello_world), # You know what this is :P
|
path('hello_world/', hello_world), # You know what this is :P
|
||||||
path('', HomeView.as_view(), name='home'),
|
path('', HomeView.as_view(), name='home'),
|
||||||
path('signup/', SignUpView.as_view(), name='signup'),
|
path('signup/', SignUpView.as_view(), name='signup'),
|
||||||
path('place/<int:pk>/', place_detail_view, name='place_detail'),
|
path('place/<int:pk>/', place_detail_view, name='place_detail'),
|
||||||
path('place/create/', PlaceCreateView.as_view(), name='place_create'),
|
path('place/create/', PlaceCreateView.as_view(), name='place_create'),
|
||||||
|
@ -29,12 +29,12 @@ def hello_world(request):
|
|||||||
return render(request, 'hello_world.html', {'text':'Hello World!'})
|
return render(request, 'hello_world.html', {'text':'Hello World!'})
|
||||||
|
|
||||||
class HomeView(View):
|
class HomeView(View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
place_list = Place.objects.all().order_by('submitted_when')[:10]
|
place_list = Place.objects.all().order_by('submitted_when')[:10]
|
||||||
context = {
|
context = {
|
||||||
'place_list': place_list
|
'place_list': place_list
|
||||||
}
|
}
|
||||||
return render(request, 'home.html', context)
|
return render(request, 'home.html', context)
|
||||||
|
|
||||||
class PlaceUpdateView(UpdateView):
|
class PlaceUpdateView(UpdateView):
|
||||||
template_name = 'update_place.html'
|
template_name = 'update_place.html'
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
<h2>Login</h2>
|
<h2>Login</h2>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
@ -7,38 +7,38 @@
|
|||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
|
|
||||||
<form class="LP-Form" method="POST">
|
<form class="LP-Form" method="POST">
|
||||||
<fieldset class="LP-Form__Fieldset">
|
<fieldset class="LP-Form__Fieldset">
|
||||||
<legend class="LP-Form__Legend">Registrierung</legend>
|
<legend class="LP-Form__Legend">Registrierung</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
<div class="LP-Form__Composition LP-Form__Composition--breakable">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.username %}
|
{% include 'partials/form/inputField.html' with field=form.username %}
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.email %}
|
{% include 'partials/form/inputField.html' with field=form.email %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.password1 %}
|
{% include 'partials/form/inputField.html' with field=form.password1 %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.password2 %}
|
{% include 'partials/form/inputField.html' with field=form.password2 %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=form.voucher %}
|
{% include 'partials/form/inputField.html' with field=form.voucher %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<input type="submit" class="LP-Button" value="Registrieren"/>
|
<input type="submit" class="LP-Button" value="Registrieren"/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user