Compare commits
95 Commits
feature/33
...
master
Author | SHA1 | Date | |
---|---|---|---|
f078afcdcd | |||
163e9beb51 | |||
6ba225bee3 | |||
a4f80820c9 | |||
0f7b799c11 | |||
b23dc8a627 | |||
3e2ab1e12d | |||
78efe9bebb | |||
1de203ad40 | |||
399fa70ab6 | |||
c6a28c7b66 | |||
9980a2d190 | |||
1bc283bd8d | |||
4c43f87560 | |||
c8399b9ce4 | |||
f7dab77229 | |||
8d96214a92 | |||
6678f8ff02 | |||
4cd0635d5f | |||
e11151858b | |||
84b01f3a9a | |||
3f4bf9475c | |||
b607335299 | |||
b1cd8fd0cc | |||
a7a3ddfe63 | |||
1c6366fb43 | |||
565a70bbac | |||
749aa61828 | |||
e2754dc56c | |||
|
fefc38fa9c | ||
|
58ab70ba42 | ||
|
c63b0ebb87 | ||
|
0852e35b57 | ||
e52247d80b | |||
2ac90bd35c | |||
3685db6892 | |||
d5789cef75 | |||
5fca4dc52a | |||
cbf45af5f5 | |||
244b4d2917 | |||
d8b0ce1ac2 | |||
8da6964b3c | |||
ccd701ea60 | |||
170971c44b | |||
7196820122 | |||
a02d4f5e86 | |||
a7043651e0 | |||
bcf3377190 | |||
ceabe3f6f8 | |||
6b33d20f90 | |||
1d787a3b1d | |||
1960bf3792 | |||
0c3898163e | |||
2c6676d2c9 | |||
52f9df8b2a | |||
ab669b9f5e | |||
0fe98d4f8f | |||
51addd8fbb | |||
29d2813fcc | |||
cc9343270a | |||
4f465b3162 | |||
b0bf40aa0b | |||
822a536ebe | |||
5b9672e21e | |||
0a5d22d4d9 | |||
9c86eab14c | |||
29d067002e | |||
f5f5980f9b | |||
10c08a2f5e | |||
50f60be10a | |||
8b32b56dd9 | |||
74d842a668 | |||
2ac39f719f | |||
9b6121e448 | |||
a139594863 | |||
f2eb048f0b | |||
120e63808a | |||
201ef73639 | |||
af7afd0311 | |||
cf6346fdf0 | |||
d641d7b44d | |||
d35cb8131a | |||
ceeae9e8c9 | |||
092b91825f | |||
52271811ad | |||
fb1237f111 | |||
bae4e13137 | |||
b752454233 | |||
36eb9566d9 | |||
b876435d8c | |||
224eb87d76 | |||
a78f123d1f | |||
947f6520aa | |||
196fb02436 | |||
9be993d9ba |
1
.gitignore
vendored
1
.gitignore
vendored
@ -79,7 +79,6 @@ Pipfile.lock
|
|||||||
__pypackages__/
|
__pypackages__/
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
|
42
Jenkinsfile
vendored
Normal file
42
Jenkinsfile
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'kennethreitz/pipenv'
|
||||||
|
args '--user root --privileged'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('setup') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh 'pipenv install'
|
||||||
|
sh 'pipenv install --dev'
|
||||||
|
sh 'pip install setuptools'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('migration') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh 'pipenv run makemigrations'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('build') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh 'pipenv run build'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
success {
|
||||||
|
archiveArtifacts artifacts: 'dist/*.whl', fingerprint: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
Pipfile
10
Pipfile
@ -12,6 +12,9 @@ wheel = "*"
|
|||||||
twine = "*"
|
twine = "*"
|
||||||
pandoc = "*"
|
pandoc = "*"
|
||||||
pylint-django = "*"
|
pylint-django = "*"
|
||||||
|
setuptools = "*"
|
||||||
|
django-nose = "*"
|
||||||
|
invoke = "*"
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
django = "*"
|
django = "*"
|
||||||
@ -25,3 +28,10 @@ test = "django_lostplaces/manage.py test lostplaces"
|
|||||||
server = "django_lostplaces/manage.py runserver --ipv6"
|
server = "django_lostplaces/manage.py runserver --ipv6"
|
||||||
dbshell = "django_lostplaces/manage.py dbshell"
|
dbshell = "django_lostplaces/manage.py dbshell"
|
||||||
showmigrations = "django_lostplaces/manage.py showmigrations"
|
showmigrations = "django_lostplaces/manage.py showmigrations"
|
||||||
|
makemigrations = "django_lostplaces/manage.py makemigrations --no-input"
|
||||||
|
migrate = "django_lostplaces/manage.py migrate"
|
||||||
|
build = "django_lostplaces/setup.py bdist_wheel --universal"
|
||||||
|
createsuperuser = "django_lostplaces/manage.py createsuperuser --noinput --username admin --email admin@example.org"
|
||||||
|
createsuperuser_prompt = "django_lostplaces/manage.py createsuperuser"
|
||||||
|
quickstart = "invoke quickstart"
|
||||||
|
security = "pipenv check"
|
17
Readme.md
17
Readme.md
@ -35,7 +35,7 @@ Right now it depends on the following non-core Python 3 libraries. These can be
|
|||||||
|
|
||||||
# Installing a development instance
|
# Installing a development instance
|
||||||
## Clone the repository
|
## Clone the repository
|
||||||
`git clone https://git.mowoe.com/reverend/lostplaces-backend.git`
|
`git clone https://git.commander1024.de/Commander1024/lostplaces-backend`
|
||||||
## Setting up a (pipenv) virtual environment for development
|
## Setting up a (pipenv) virtual environment for development
|
||||||
|
|
||||||
After having obtained the repository contents (either via .zip download or git clone), you can easily setup a [pipenv](https://docs.pipenv.org/) virtual environment. The repo provides a Pipfile for easy dependency management that does not mess with your system.
|
After having obtained the repository contents (either via .zip download or git clone), you can easily setup a [pipenv](https://docs.pipenv.org/) virtual environment. The repo provides a Pipfile for easy dependency management that does not mess with your system.
|
||||||
@ -65,6 +65,21 @@ Visit: [admin](http://localhost:8000/admin) for administrative backend or
|
|||||||
|
|
||||||
Happy developing ;-)
|
Happy developing ;-)
|
||||||
|
|
||||||
|
# Pipenv Scripts
|
||||||
|
This project comes with a bunch of convinient scripts, like:
|
||||||
|
|Script|Description|
|
||||||
|
|---|---|
|
||||||
|
|test|Runs the tests|
|
||||||
|
|server|Starts a **development** server|
|
||||||
|
|dbshell|Opens a shell session in the database|
|
||||||
|
|showmigrations|Lists all Migrations|
|
||||||
|
|makemigrations|Creates a migration|
|
||||||
|
|migrate|Applies unapplied migrations|
|
||||||
|
|build|Builds this project into a wheel file|
|
||||||
|
|createsuperuser|Creates a superuser with the username **admin** and the password **develop**. This is for development and demo instances only!
|
||||||
|
|quickstart|Runs *migrate*, *createsuperuser* and *server*|
|
||||||
|
|
||||||
|
|
||||||
# Installing a productive instance
|
# Installing a productive instance
|
||||||
|
|
||||||
Currently there are two ways to deploy the lostplaces project:
|
Currently there are two ways to deploy the lostplaces project:
|
||||||
|
@ -49,7 +49,15 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles'
|
'django.contrib.staticfiles',
|
||||||
|
'django_nose'
|
||||||
|
]
|
||||||
|
|
||||||
|
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
|
||||||
|
|
||||||
|
NOSE_ARGS = [
|
||||||
|
'--with-coverage',
|
||||||
|
'--cover-package=lostplaces',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
@ -28,6 +28,6 @@ from lostplaces.views import SignUpView
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('signup/', SignUpView.as_view(), name='signup'),
|
path('signup/', SignUpView.as_view(), name='signup'),
|
||||||
path('explorers/', include('django.contrib.auth.urls')),
|
path('explorer/', include('django.contrib.auth.urls')),
|
||||||
path('', include('lostplaces.urls')),
|
path('', include('lostplaces.urls')),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
@ -5,7 +5,7 @@ from django.conf import settings
|
|||||||
|
|
||||||
settings.THUMBNAIL_ALIASES = {
|
settings.THUMBNAIL_ALIASES = {
|
||||||
'': {
|
'': {
|
||||||
'thumbnail': {'size': (300, 200), 'sharpen': True, 'crop': True},
|
'thumbnail': {'size': (300, 200), 'sharpen': True, 'crop': True, 'upscale': True},
|
||||||
'hero': {'size': (700, 466), 'sharpen': True, 'crop': True},
|
'hero': {'size': (700, 466), 'sharpen': True, 'crop': True},
|
||||||
'large': {'size': (1920, 1920), 'sharpen': True, 'crop': False},
|
'large': {'size': (1920, 1920), 'sharpen': True, 'crop': False},
|
||||||
},
|
},
|
||||||
|
@ -35,3 +35,4 @@ admin.site.register(Voucher, VoucherAdmin)
|
|||||||
admin.site.register(Place, PlacesAdmin)
|
admin.site.register(Place, PlacesAdmin)
|
||||||
admin.site.register(PlaceImage, PlaceImagesAdmin)
|
admin.site.register(PlaceImage, PlaceImagesAdmin)
|
||||||
admin.site.register(PhotoAlbum, PhotoAlbumsAdmin)
|
admin.site.register(PhotoAlbum, PhotoAlbumsAdmin)
|
||||||
|
admin.site.register(PlaceVoting)
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
|
||||||
class LostplacesAppConfig(AppConfig):
|
class LostplacesAppConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.AutoField'
|
||||||
name = 'lostplaces'
|
name = 'lostplaces'
|
||||||
|
@ -8,6 +8,8 @@ from django.db import models
|
|||||||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from lostplaces import widgets
|
||||||
from lostplaces.models import Place, PlaceImage, Voucher, Explorer
|
from lostplaces.models import Place, PlaceImage, Voucher, Explorer
|
||||||
|
|
||||||
class SignupVoucherForm(UserCreationForm):
|
class SignupVoucherForm(UserCreationForm):
|
||||||
@ -20,7 +22,7 @@ class SignupVoucherForm(UserCreationForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
super().is_valid()
|
super_result = super().is_valid()
|
||||||
submitted_voucher = self.cleaned_data.get('voucher')
|
submitted_voucher = self.cleaned_data.get('voucher')
|
||||||
try:
|
try:
|
||||||
fetched_voucher = Voucher.objects.get(code=submitted_voucher)
|
fetched_voucher = Voucher.objects.get(code=submitted_voucher)
|
||||||
@ -33,7 +35,7 @@ class SignupVoucherForm(UserCreationForm):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
fetched_voucher.delete()
|
fetched_voucher.delete()
|
||||||
return True
|
return super_result
|
||||||
|
|
||||||
class ExplorerUserChangeForm(UserChangeForm):
|
class ExplorerUserChangeForm(UserChangeForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -61,20 +63,29 @@ class ExplorerChangeForm(forms.ModelForm):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = Explorer
|
model = Explorer
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
exclude = ['user', 'favorite_places']
|
exclude = ['user', 'favorite_places', 'level']
|
||||||
|
|
||||||
class PlaceForm(forms.ModelForm):
|
class PlaceForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Place
|
model = Place
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
exclude = ['submitted_by', 'latitude', 'longitute']
|
exclude = ['submitted_by', 'level']
|
||||||
|
widgets = {
|
||||||
|
'hero': widgets.SelectContent()
|
||||||
|
}
|
||||||
|
|
||||||
latitude = forms.IntegerField(
|
def __init__(self, *args, **kwargs):
|
||||||
widget=forms.NumberInput(attrs={'min':-90,'max': 90,'type': 'number'})
|
super().__init__(*args, **kwargs)
|
||||||
|
if 'instance' in kwargs:
|
||||||
|
self.fields['hero'].queryset = PlaceImage.objects.filter(place=kwargs['instance'])
|
||||||
|
self.fields['hero'].widget.attrs['item_template'] = 'partials/select_place_image_item.html'
|
||||||
|
|
||||||
|
latitude = forms.DecimalField(
|
||||||
|
widget=forms.NumberInput(attrs={'min':-90,'max': 90,'type': 'number', 'step': 'any'})
|
||||||
)
|
)
|
||||||
|
|
||||||
longitude = forms.IntegerField(
|
longitude = forms.DecimalField(
|
||||||
widget=forms.NumberInput(attrs={'min':-180,'max': 180,'type': 'number'})
|
widget=forms.NumberInput(attrs={'min':-180,'max': 180,'type': 'number', 'step': 'any'})
|
||||||
)
|
)
|
||||||
|
|
||||||
class PlaceImageForm(forms.ModelForm):
|
class PlaceImageForm(forms.ModelForm):
|
||||||
@ -90,6 +101,21 @@ class PlaceImageForm(forms.ModelForm):
|
|||||||
|
|
||||||
self.fields['filename'].required = False
|
self.fields['filename'].required = False
|
||||||
|
|
||||||
|
class PlaceSetHeroForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Place
|
||||||
|
fields = ['hero']
|
||||||
|
widgets = {
|
||||||
|
'hero': widgets.SelectContent()
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['hero'].queryset = PlaceImage.objects.filter(place=kwargs['instance'])
|
||||||
|
self.fields['hero'].widget.attrs['item_template'] = 'partials/select_place_image_item.html'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TagSubmitForm(forms.Form):
|
class TagSubmitForm(forms.Form):
|
||||||
tag_list = forms.CharField(
|
tag_list = forms.CharField(
|
||||||
max_length=500,
|
max_length=500,
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
# Generated by Django 3.1.4 on 2020-12-25 16:02
|
# Generated by Django 3.1.1 on 2020-12-19 13:53
|
||||||
|
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
import easy_thumbnails.fields
|
import easy_thumbnails.fields
|
||||||
from lostplaces.models.models import generate_profile_image_filename
|
import lostplaces.models.place
|
||||||
from lostplaces.models.place import generate_place_image_filename
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -15,21 +14,6 @@ class Migration(migrations.Migration):
|
|||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AddField(
|
|
||||||
model_name='explorer',
|
|
||||||
name='bio',
|
|
||||||
field=models.TextField(blank=True, help_text='Describe yourself, your preferences, etc. in a few sentences.', null=True, verbose_name='Biography / Description'),
|
|
||||||
),
|
|
||||||
# migrations.AddField(
|
|
||||||
# model_name='explorer',
|
|
||||||
# name='favorite_places',
|
|
||||||
# field=models.ManyToManyField(blank=True, related_name='explorer_favorites', to='lostplaces.Place', verbose_name='Explorers favorite places'),
|
|
||||||
# ),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='explorer',
|
|
||||||
name='profile_image',
|
|
||||||
field=easy_thumbnails.fields.ThumbnailerImageField(blank=True, help_text='Optional profile image for display in Explorer profile', null=True, upload_to=generate_profile_image_filename, verbose_name='Profile image'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='photoalbum',
|
model_name='photoalbum',
|
||||||
name='label',
|
name='label',
|
||||||
@ -93,7 +77,7 @@ class Migration(migrations.Migration):
|
|||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='placeimage',
|
model_name='placeimage',
|
||||||
name='filename',
|
name='filename',
|
||||||
field=easy_thumbnails.fields.ThumbnailerImageField(help_text='Optional: One or more images to upload', upload_to=generate_place_image_filename, verbose_name='Filename(s)'),
|
field=easy_thumbnails.fields.ThumbnailerImageField(help_text='Optional: One or more images to upload', upload_to=lostplaces.models.place.generate_image_upload_path, verbose_name='Filename(s)'),
|
||||||
),
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='placeimage',
|
model_name='placeimage',
|
@ -1,18 +0,0 @@
|
|||||||
# Generated by Django 3.1.4 on 2020-12-25 18:14
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('lostplaces', '0004_auto_20201225_1702'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='explorer',
|
|
||||||
name='visited_places',
|
|
||||||
field=models.ManyToManyField(blank=True, related_name='explorer_visits', to='lostplaces.Place', verbose_name='Explorers visited places'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -0,0 +1,85 @@
|
|||||||
|
# Generated by Django 3.2.10 on 2021-12-31 17:20
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import easy_thumbnails.fields
|
||||||
|
import lostplaces.models.models
|
||||||
|
import lostplaces.models.place
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lostplaces', '0004_release_0_1_3'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='explorer',
|
||||||
|
name='bio',
|
||||||
|
field=models.TextField(blank=True, help_text='Describe yourself, your preferences, etc. in a few sentences.', null=True, verbose_name='Biography / Description'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='explorer',
|
||||||
|
name='favorite_places',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='explorer_favorites', to='lostplaces.Place', verbose_name='Explorers favorite places'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='explorer',
|
||||||
|
name='level',
|
||||||
|
field=models.IntegerField(choices=[(1, 'Newbie'), (2, 'Scout'), (3, 'Explorer'), (4, 'Journalist'), (5, 'Housekeeper')], default=1),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='explorer',
|
||||||
|
name='profile_image',
|
||||||
|
field=easy_thumbnails.fields.ThumbnailerImageField(blank=True, help_text='Optional profile image for display in Explorer profile', null=True, upload_to=lostplaces.models.generate_profile_image_filename, verbose_name='Profile image'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='explorer',
|
||||||
|
name='visited_places',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='explorer_visits', to='lostplaces.Place', verbose_name='Explorers visited places'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='place',
|
||||||
|
name='hero',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='place_heros', to='lostplaces.placeimage'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='place',
|
||||||
|
name='level',
|
||||||
|
field=models.IntegerField(choices=[(1, 'Ruin'), (2, 'Vandalized'), (3, 'Natures Treasure'), (4, 'Lost in History'), (5, 'Time Capsule')], default=5),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='placeimage',
|
||||||
|
name='filename',
|
||||||
|
field=easy_thumbnails.fields.ThumbnailerImageField(help_text='Optional: One or more images to upload', upload_to=lostplaces.models.place.generate_place_image_filename, verbose_name='Images'),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PlaceVoting',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('submitted_when', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date')),
|
||||||
|
('created_when', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')),
|
||||||
|
('expires_when', models.DateTimeField(verbose_name='Expiration date')),
|
||||||
|
('vote', models.IntegerField(choices=[(1, 'Ruin'), (2, 'Vandalized'), (3, 'Natures Treasure'), (4, 'Lost in History'), (5, 'Time Capsule')])),
|
||||||
|
('place', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='placevotings', to='lostplaces.place')),
|
||||||
|
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='placevotings', to='lostplaces.explorer', verbose_name='Submitter')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DummyAsset',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('submitted_when', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date')),
|
||||||
|
('name', models.CharField(max_length=50)),
|
||||||
|
('place', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dummyassets', to='lostplaces.place')),
|
||||||
|
('submitted_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dummyassets', to='lostplaces.explorer', verbose_name='Submitter')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
@ -29,6 +29,14 @@ def generate_profile_image_filename(instance, filename):
|
|||||||
|
|
||||||
return 'explorers/' + str(instance.user.pk) + '-' + str(instance.user.username) + '.' + filename.split('.')[-1]
|
return 'explorers/' + str(instance.user.pk) + '-' + str(instance.user.username) + '.' + filename.split('.')[-1]
|
||||||
|
|
||||||
|
EXPLORER_LEVELS = (
|
||||||
|
(1, 'Newbie'),
|
||||||
|
(2, 'Scout'),
|
||||||
|
(3, 'Explorer'),
|
||||||
|
(4, 'Journalist'),
|
||||||
|
(5, 'Housekeeper')
|
||||||
|
)
|
||||||
|
|
||||||
class Explorer(models.Model):
|
class Explorer(models.Model):
|
||||||
"""
|
"""
|
||||||
Profile that is linked to the Django user.
|
Profile that is linked to the Django user.
|
||||||
@ -69,6 +77,23 @@ class Explorer(models.Model):
|
|||||||
blank=True
|
blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
level = models.IntegerField(
|
||||||
|
default=1,
|
||||||
|
choices=EXPLORER_LEVELS
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_places_eligible_to_see(self):
|
||||||
|
if self.user.is_superuser:
|
||||||
|
return Place.objects.all()
|
||||||
|
return Place.objects.all().filter(level__lte=self.level) | self.places.all()
|
||||||
|
|
||||||
|
def is_eligible_to_see(self, place):
|
||||||
|
return (
|
||||||
|
self.user.is_superuser or
|
||||||
|
place.submitted_by == self or
|
||||||
|
place in self.get_places_eligible_to_see()
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.username
|
return self.user.username
|
||||||
|
|
||||||
@ -95,7 +120,6 @@ def auto_delete_file_on_change(sender, instance, **kwargs):
|
|||||||
old_file = Explorer.objects.get(pk=instance.pk).profile_image
|
old_file = Explorer.objects.get(pk=instance.pk).profile_image
|
||||||
except Explorer.DoesNotExist:
|
except Explorer.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
print("Deleting:", old_file)
|
|
||||||
new_file = instance.profile_image
|
new_file = instance.profile_image
|
||||||
if not old_file == new_file:
|
if not old_file == new_file:
|
||||||
old_file.delete(save=False)
|
old_file.delete(save=False)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from math import floor
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -6,11 +7,19 @@ from django.dispatch import receiver
|
|||||||
from django.db.models.signals import post_delete, pre_save
|
from django.db.models.signals import post_delete, pre_save
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from lostplaces.models.abstract_models import Submittable, Taggable, Mapable
|
from lostplaces.models.abstract_models import Submittable, Taggable, Mapable, Expireable
|
||||||
|
|
||||||
from easy_thumbnails.fields import ThumbnailerImageField
|
from easy_thumbnails.fields import ThumbnailerImageField
|
||||||
from easy_thumbnails.files import get_thumbnailer
|
from easy_thumbnails.files import get_thumbnailer
|
||||||
|
|
||||||
|
PLACE_LEVELS = (
|
||||||
|
(1, 'Ruin'),
|
||||||
|
(2, 'Vandalized'),
|
||||||
|
(3, 'Natures Treasure'),
|
||||||
|
(4, 'Lost in History'),
|
||||||
|
(5, 'Time Capsule')
|
||||||
|
)
|
||||||
|
|
||||||
class Place(Submittable, Taggable, Mapable):
|
class Place(Submittable, Taggable, Mapable):
|
||||||
"""
|
"""
|
||||||
Place defines a lost place (location, name, description etc.).
|
Place defines a lost place (location, name, description etc.).
|
||||||
@ -25,17 +34,53 @@ class Place(Submittable, Taggable, Mapable):
|
|||||||
verbose_name=_('Description'),
|
verbose_name=_('Description'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
hero = models.ForeignKey(
|
||||||
|
'PlaceImage',
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
related_name='place_heros'
|
||||||
|
)
|
||||||
|
|
||||||
|
level = models.IntegerField(
|
||||||
|
default=5,
|
||||||
|
choices=PLACE_LEVELS
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_hero_image(self):
|
||||||
|
if self.hero:
|
||||||
|
return self.hero
|
||||||
|
elif len(self.placeimages.all()) > 0:
|
||||||
|
return self.placeimages.first()
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('place_detail', kwargs={'pk': self.pk})
|
return reverse('place_detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
def get_hero_index_in_queryset(self):
|
||||||
|
'''
|
||||||
|
Calculates the index of the hero image within
|
||||||
|
the list / queryset of images. Necessary for
|
||||||
|
the lightbox.
|
||||||
|
'''
|
||||||
|
for i in range(0, len(self.placeimages.all())):
|
||||||
|
image = self.placeimages.all()[i]
|
||||||
|
if image == self.hero:
|
||||||
|
return i
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
# Get center position of LP-geocoordinates.
|
# Get center position of LP-geocoordinates.
|
||||||
def average_latlon(cls, place_list):
|
def average_latlon(cls, place_list):
|
||||||
amount = len(place_list)
|
amount = len(place_list)
|
||||||
# Init fill values to prevent None
|
# Init fill values to prevent None
|
||||||
longitude = 0
|
# China Corner in Münster
|
||||||
latitude = 0
|
# Where I almost always eat lunch
|
||||||
|
# (Does'nt help losing wheight, tho)
|
||||||
|
longitude = 7.6295628132604385
|
||||||
|
latitude = 51.961922091398904
|
||||||
|
|
||||||
if amount > 0:
|
if amount > 0:
|
||||||
for place in place_list:
|
for place in place_list:
|
||||||
@ -45,10 +90,30 @@ class Place(Submittable, Taggable, Mapable):
|
|||||||
|
|
||||||
return {'latitude': latitude, 'longitude': longitude}
|
return {'latitude': latitude, 'longitude': longitude}
|
||||||
|
|
||||||
|
def calculate_place_level(self):
|
||||||
|
self.remove_expired_votes()
|
||||||
|
|
||||||
|
if self.placevotings.count() == 0:
|
||||||
|
self.level = 5
|
||||||
|
self.save()
|
||||||
|
return
|
||||||
|
|
||||||
|
level = 0
|
||||||
|
|
||||||
|
for vote in self.placevotings.all():
|
||||||
|
level += vote.vote
|
||||||
|
|
||||||
|
self.level = floor(level / self.placevotings.count())
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
def remove_expired_votes(self):
|
||||||
|
for vote in self.placevotings.all():
|
||||||
|
if vote.is_expired:
|
||||||
|
vote.delete()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
def generate_place_image_filename(instance, filename):
|
def generate_place_image_filename(instance, filename):
|
||||||
"""
|
"""
|
||||||
Callback for generating filename for uploaded place images.
|
Callback for generating filename for uploaded place images.
|
||||||
@ -57,6 +122,9 @@ def generate_place_image_filename(instance, filename):
|
|||||||
|
|
||||||
return 'places/' + str(instance.place.pk) + '-' + str(instance.place.name) + '.' + filename.split('.')[-1]
|
return 'places/' + str(instance.place.pk) + '-' + str(instance.place.name) + '.' + filename.split('.')[-1]
|
||||||
|
|
||||||
|
def generate_image_upload_path(instance, filename):
|
||||||
|
return generate_place_image_filename(instance, filename)
|
||||||
|
|
||||||
class PlaceAsset(Submittable):
|
class PlaceAsset(Submittable):
|
||||||
"""
|
"""
|
||||||
Assets to a place, i.e. images
|
Assets to a place, i.e. images
|
||||||
@ -72,6 +140,9 @@ class PlaceAsset(Submittable):
|
|||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class DummyAsset(PlaceAsset):
|
||||||
|
name = models.CharField(max_length=50)
|
||||||
|
|
||||||
class PlaceImage(PlaceAsset):
|
class PlaceImage(PlaceAsset):
|
||||||
"""
|
"""
|
||||||
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/.
|
||||||
@ -87,7 +158,7 @@ class PlaceImage(PlaceAsset):
|
|||||||
upload_to=generate_place_image_filename,
|
upload_to=generate_place_image_filename,
|
||||||
resize_source=dict(size=(2560, 2560),
|
resize_source=dict(size=(2560, 2560),
|
||||||
sharpen=True),
|
sharpen=True),
|
||||||
verbose_name=_('Filename(s)'),
|
verbose_name=_('Images'),
|
||||||
help_text=_('Optional: One or more images to upload')
|
help_text=_('Optional: One or more images to upload')
|
||||||
)
|
)
|
||||||
place = models.ForeignKey(
|
place = models.ForeignKey(
|
||||||
@ -102,7 +173,7 @@ class PlaceImage(PlaceAsset):
|
|||||||
of this image as textual representation of this instance
|
of this image as textual representation of this instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return 'Image ' + str(self.pk)
|
return 'Image ' + str(self.place.name)
|
||||||
|
|
||||||
# These two auto-delete files from filesystem when they are unneeded:
|
# These two auto-delete files from filesystem when they are unneeded:
|
||||||
|
|
||||||
@ -136,3 +207,13 @@ def auto_delete_file_on_change(sender, instance, **kwargs):
|
|||||||
new_file = instance.filename
|
new_file = instance.filename
|
||||||
if not old_file == new_file:
|
if not old_file == new_file:
|
||||||
old_file.delete(save=False)
|
old_file.delete(save=False)
|
||||||
|
|
||||||
|
|
||||||
|
class PlaceVoting(PlaceAsset, Expireable):
|
||||||
|
vote = models.IntegerField(choices=PLACE_LEVELS)
|
||||||
|
|
||||||
|
def get_human_readable_level(self):
|
||||||
|
return PLACE_LEVELS[self.vote - 1][1]
|
||||||
|
|
||||||
|
def get_all_choices(self):
|
||||||
|
return reversed(PLACE_LEVELS)
|
@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
19116
django_lostplaces/lostplaces/static/materialdesignicons.css
Normal file
19116
django_lostplaces/lostplaces/static/materialdesignicons.css
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
{% extends 'global.html'%}
|
{% extends 'global.html'%}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Forbidden' %}{% endblock %}
|
{% block title %}{% translate 'Forbidden' %}{% endblock %}
|
||||||
|
|
||||||
{% block additional_head %}
|
{% block additional_head %}
|
||||||
{% if request.META.HTTP_REFERER %}
|
{% if request.META.HTTP_REFERER %}
|
||||||
@ -11,6 +11,6 @@
|
|||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
{% if request.META.HTTP_REFERER %}
|
{% if request.META.HTTP_REFERER %}
|
||||||
<p class="LP-Headline">{% trans 'You will be redirected in 5 seconds' %}</p><p class="LP-Headline"><a href="{{ request.META.HTTP_REFERER }}" class="LP-Link">{% trans 'Go Back' %}</a></p>
|
<p class="LP-Headline">{% translate 'You will be redirected in 5 seconds' %}</p><p class="LP-Headline"><a href="{{ request.META.HTTP_REFERER }}" class="LP-Link">{% translate 'Go Back' %}</a></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
@ -42,14 +42,14 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="LP-UserInfo__Value">
|
<td class="LP-UserInfo__Value">
|
||||||
<span class="LP-Paragraph">
|
<span class="LP-Paragraph">
|
||||||
<a href="{{explorer.user.email}}" class="LP-Link">{{explorer.user.email}}</a>
|
<a href="mailto:{{explorer.user.email}}" class="LP-Link">{{explorer.user.email}}</a>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="LP-UserInfo__Key">
|
<td class="LP-UserInfo__Key">
|
||||||
<span class="LP-Paragraph">{% trans 'Joined' %}</span>
|
<span class="LP-Paragraph">{% translate 'Joined' %}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="LP-UserInfo__Value">
|
<td class="LP-UserInfo__Value">
|
||||||
<span class="LP-Paragraph">{{explorer.user.date_joined|date:'d.m.Y'}}</span>
|
<span class="LP-Paragraph">{{explorer.user.date_joined|date:'d.m.Y'}}</span>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="LP-UserInfo__Key">
|
<td class="LP-UserInfo__Key">
|
||||||
<span class="LP-Paragraph">{% trans 'Places'%}</span>
|
<span class="LP-Paragraph">{% translate 'Places'%}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="LP-UserInfo__Value">
|
<td class="LP-UserInfo__Value">
|
||||||
<span class="LP-Paragraph">{{place_count}}</span>
|
<span class="LP-Paragraph">{{place_count}}</span>
|
||||||
@ -65,18 +65,16 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="LP-UserInfo__Key">
|
<td class="LP-UserInfo__Key">
|
||||||
<span class="LP-Paragraph">{% trans 'Place assets'%}</span>
|
<span class="LP-Paragraph">{% translate 'Place Assets'%}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="LP-UserInfo__Value">
|
<td class="LP-UserInfo__Value">
|
||||||
<span class="LP-Paragraph">{{asset_count}}</span>
|
<span class="LP-Paragraph">{{asset_count}}</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="/explorer/update/"><button class="LP-Button LP-Button">{% trans 'Edit Profile' %}</button></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
|
<div class="LP-UserInfo__Edit">
|
||||||
|
<a href="{% url 'explorer_profile_update' %}" class="LP-Button LP-Button--fullWidth LP-Link">{% trans 'Edit Profile' %}</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -84,39 +82,13 @@
|
|||||||
|
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
<div class="LP-PlaceList">
|
<div class="LP-PlaceList">
|
||||||
<h1 class="LP-Headline">{% trans 'Favorite places' %}</h1>
|
<h1 class="LP-Headline">{% translate 'Places submitted by' %} {{explorer.user.username}}</h1>
|
||||||
<ul class="LP-PlaceList__List">
|
|
||||||
{% for place in explorer.favorite_places.all %}
|
|
||||||
<li class="LP-PlaceList__Item">
|
|
||||||
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% include 'partials/nav/pagination.html' %}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="LP-Section">
|
|
||||||
<div class="LP-PlaceList">
|
|
||||||
<h1 class="LP-Headline">{% trans 'Visited places' %}</h1>
|
|
||||||
<ul class="LP-PlaceList__List">
|
|
||||||
{% for place in explorer.visited_places.all %}
|
|
||||||
<li class="LP-PlaceList__Item">
|
|
||||||
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% include 'partials/nav/pagination.html' %}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="LP-Section">
|
|
||||||
<div class="LP-PlaceList">
|
|
||||||
<h1 class="LP-Headline">{% trans 'Places submitted by' %} {{explorer.user.username}}</h1>
|
|
||||||
<ul class="LP-PlaceList__List">
|
<ul class="LP-PlaceList__List">
|
||||||
{% for place in place_list %}
|
{% for place in place_list %}
|
||||||
<li class="LP-PlaceList__Item">
|
<li class="LP-PlaceList__Item">
|
||||||
|
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
||||||
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
{% include 'partials/place_teaser.html' with place=place extended=True %}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@ -127,29 +99,12 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Images submitted by' %} {{explorer.user.username}}</h1>
|
{% translate 'Images submitted by' as submitted_by %}
|
||||||
<div class="LP-ImageGrid">
|
{% include 'partials/placeImageGrid.html' with headline=submitted_by|add:' '|add:explorer.user.username image_list=assets.placeimages.all%}
|
||||||
<ul class="LP-ImageGrid__Container">
|
|
||||||
{% for place_image in assets.placeimages.all %}
|
|
||||||
<li class="LP-ImageGrid__Item">
|
|
||||||
<a href="{{ place_image.filename.large.url }}" class="LP-Link">
|
|
||||||
<img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}">
|
|
||||||
</a>
|
|
||||||
{% if user.explorer == place_image.submitted_by%}
|
|
||||||
<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
|
|
||||||
<a href="{% url 'place_image_delete' pk=place_image.id %}" class="LP-Link">
|
|
||||||
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}" />
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class=" LP-Section">
|
<section class=" LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Photo albums submitted by' %} {{explorer.user.username}}</h1>
|
<h1 class="LP-Headline">{% translate 'Photo albums submitted by' %} {{explorer.user.username}}</h1>
|
||||||
<div class="LP-LinkList">
|
<div class="LP-LinkList">
|
||||||
<ul class="LP-LinkList__Container">
|
<ul class="LP-LinkList__Container">
|
||||||
{% for photo_album in assets.photoalbums.all %}
|
{% for photo_album in assets.photoalbums.all %}
|
||||||
|
@ -11,7 +11,26 @@
|
|||||||
<article class="LP-TextSection LP-TextSection__Text">
|
<article class="LP-TextSection LP-TextSection__Text">
|
||||||
|
|
||||||
<p>Das sollte doch eigentlich eindeutig sein, oder? Aber wie wir alle wissen, hat jedes Schild eine Geschichte. Wir haben zu viel sinnlose Zerstörung gesehen, sodass wir uns dazu entschieden haben, einen grundlegenden Urban Exploration Codex niederzuschreiben.</p>
|
<p>Das sollte doch eigentlich eindeutig sein, oder? Aber wie wir alle wissen, hat jedes Schild eine Geschichte. Wir haben zu viel sinnlose Zerstörung gesehen, sodass wir uns dazu entschieden haben, einen grundlegenden Urban Exploration Codex niederzuschreiben.</p>
|
||||||
<ul class="LP-UnorderedList">
|
<h2 class="LP-Headline">Zu deiner eigenen Sicherheit</h2>
|
||||||
|
<ol class="LP-UnorderedList">
|
||||||
|
<li>
|
||||||
|
<b>Wir gehen selten alleine</b>, ein bisschen rumlaufen und Fotos machen klingt erstmal ungefährlich. Du weißt aber nie in welchem Zustand die Anlage ist oder wer sich dort aufhält. Den Fuß umknickt, an Scherben geschnitten oder vielleicht auf einen unerwarteten Bewohner oder Sicherheitspersonal getroffen. In solchen Situationen ist immer besser jemanden an deiner Seite zu haben, der dich nicht im Stich lässt.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Wir sagen vor einer Tour mindestens einer Person unseres Vertrauens, wo wir sind</b> (Koordinaten!), wie lange wir uns dort aufhalten werden und was wir dort tun. Wir verabreden, daß wir uns bei einem längeren Aufenthalt dort regelmäßig melden, oder aber ein "okay" geben, wenn wir die Location wieder verlassen haben. Wenn wir uns verspäten, dann denken wir daran, eine entsprechende Nachricht abzusetzen. Unsere Kontaktperson soll nach einer gewissen Zeit, wenn sie nichts von mir hört, für Hilfe sorgen.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>In einer Location verhalten wir uns vorsichtig.</b> Wir werfen nichts in Löcher oder aus Fenstern und berühren auch keine elektrischen Anlagen. Nicht immer ist der Strom wirklich abgeschaltet. Deswegen öffnen wor auch keine Flaschen und andere Behälter. Wir gehen niemals ohne Licht in einen dunklen Raum, und nehmen immer eine Reservelampe mit.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Wir bereiten unsere Tour sorgfältig vor.</b> Es ist ärgerlich, wenn die Kamera-Akkus nicht geladen sind - aber gefährlich ist es keineswegs. Es ist aber lebensgefährlich, wenn ein verschmutzter Nagel durch eine Sohle getreten wird. Sicherheitsschuhe zu tragen ist eine gute Idee. Wenn wir unter Tage gehen, nehmen wir angemessenes Equipment mit um uns zu schützen — z. B. einen Gaswarner oder vllt. sogar einen Geigerzähler.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Wir rennen nicht vor bewaffnetem Personal weg</b>, insbesondere nicht der Polizei! Eine Anzeige ist ätzend und das reden mit den Beamten ist mit Sicherheit unangenehm, flieht ihr die Szene, macht euch das aber noch verdächtiger. Mal ganz davon abgesehen dass die Polizei in der Überzahl ist und euch wahrscheinlich sowie fasst.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<h2 class="LP-Headline">Damit ein Lostplace auch lost bleibt</h2>
|
||||||
|
<ol class="LP-UnorderedList">
|
||||||
<li>
|
<li>
|
||||||
<b>Wir respektieren fremdes Eigentum</b>, so wie wir das von anderen auch verlangen. Deswegen öffnen wir keinen Zugang gewaltsam, oder beschädigen eine Verschlusseinrichtung. Wir betreten ein Grundstück oder ein Gebäude / eine Anlage / eine Ruine nur dann, wenn wir davon ausgehen können, nicht gegen den Willen des Eigentümers dort zu sein. Eine gut erhaltene Umzäunung, oder ein ständiger Wachschutz sprechen dafür, dass der Eigentümer sich noch mit seiner Anlage befasst. Längst umgesunkene Zäune, Ruinen im letzten Stadium eines Verfalls sprecher dafür, dass dem Eigentümer das eher Wurst ist.
|
<b>Wir respektieren fremdes Eigentum</b>, so wie wir das von anderen auch verlangen. Deswegen öffnen wir keinen Zugang gewaltsam, oder beschädigen eine Verschlusseinrichtung. Wir betreten ein Grundstück oder ein Gebäude / eine Anlage / eine Ruine nur dann, wenn wir davon ausgehen können, nicht gegen den Willen des Eigentümers dort zu sein. Eine gut erhaltene Umzäunung, oder ein ständiger Wachschutz sprechen dafür, dass der Eigentümer sich noch mit seiner Anlage befasst. Längst umgesunkene Zäune, Ruinen im letzten Stadium eines Verfalls sprecher dafür, dass dem Eigentümer das eher Wurst ist.
|
||||||
</li>
|
</li>
|
||||||
@ -25,15 +44,6 @@
|
|||||||
<li>
|
<li>
|
||||||
<b>Sprayen ist ein absolutes "no-go"!</b>
|
<b>Sprayen ist ein absolutes "no-go"!</b>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<b>In einer Location verhalten wir uns vorsichtig.</b> Wir werfen nichts in Löcher oder aus Fenstern und berühren auch keine elektrischen Anlagen. Nicht immer ist der Strom wirklich abgeschaltet. Deswegen öffnen wor auch keine Flaschen und andere Behälter. Wir gehen niemals ohne Licht in einen dunklen Raum, und nehmen immer eine Reservelampe mit.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<b>Wir sagen vor einer Tour mindestens einer Person unseres Vertrauens, wo wir sind</b> (Koordinaten!), wie lange wir uns dort aufhalten werden und was wir dort tun. Wir verabreden, daß wir uns bei einem längeren Aufenthalt dort regelmäßig melden, oder aber ein "okay" geben, wenn wir die Location wieder verlassen haben. Wenn wir uns verspäten, dann denken wir daran, eine entsprechende Nachricht abzusetzen. Unsere Kontaktperson soll nach einer gewissen Zeit, wenn sie nichts von mir hört, für Hilfe sorgen.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<b>Wir bereiten unsere Tour sorgfältig vor.</b> Es ist ärgerlich, wenn die Kamera-Akkus nicht geladen sind - aber gefährlich ist es keineswegs. Es ist aber lebensgefährlich, wenn ein verschmutzter Nagel durch eine Sohle getreten wird. Sicherheitsschuhe zu tragen ist eine gute Idee. Wenn wir unter Tage gehen, nehmen wir angemessenes Equipment mit um uns zu schützen — z. B. einen Gaswarner oder vllt. sogar einen Geigerzähler.
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<b>Wir parken nicht so, daß Dritte auf unser Vorhaben aufmerksam werden.</b> Unser Hobby braucht keine öffentliche Aufmerksamkeit, die sich auf illegales Betreten von Grundstücken richtet (und illegal dürfte das Betreten ja meist sein ...).
|
<b>Wir parken nicht so, daß Dritte auf unser Vorhaben aufmerksam werden.</b> Unser Hobby braucht keine öffentliche Aufmerksamkeit, die sich auf illegales Betreten von Grundstücken richtet (und illegal dürfte das Betreten ja meist sein ...).
|
||||||
</li>
|
</li>
|
||||||
@ -46,7 +56,19 @@
|
|||||||
<li>
|
<li>
|
||||||
<b>Wir sorgen durch Argumente und Überzeugung dafür, daß unsere Begleiter sich ebenso verhalten!</b> In erster Linie versuchen wir durch unser eigenes Verhalten zu überzeugen.
|
<b>Wir sorgen durch Argumente und Überzeugung dafür, daß unsere Begleiter sich ebenso verhalten!</b> In erster Linie versuchen wir durch unser eigenes Verhalten zu überzeugen.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ol>
|
||||||
|
<h2 class="LP-Headline">Rechtliches (für Deutschland)</h2>
|
||||||
|
<ol class="LP-UnorderedList">
|
||||||
|
<li>
|
||||||
|
<b>Das Betreten von fremden Grundstücken ist nicht zwangsläufig Illegal.</b> In Deutschland gibt es keinen Tatbestand des Einbruchs, lediglich die dabei begangen Vergehen. Machst du nichts kaputt und stiehlst du auch nichts kann dir nur Hausfriedensbruch zur Lasst gelegt werden. Hausfriedensbruch ist in Deutschland anzeigepflichtig, werdet ihr erwischt notieren sich die Beamten eure Personalien und melden euren Besuch dem Eigentümer des Grundstücks. Dieser Entscheidet ob er gegen euch Anzeige erstattet oder nicht. Erfahrungsgemäß sind den meisten Eigentümern ein paar Leute die nur Fotos machen ziemlich egal, darauf soltet ihr euch aber nicht verlassen.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Nehmt einen Ausweis mit</b> solltet ihr erwischt werden müssen die Beamten eure Identität erfassen. Gelingt das nicht vor Ort, werdet ihr einen Ausflug auf die nächste Polizeiwache machen. Darauf haben weder ihr nocht die Beamten lust.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<b>Graffiti ist Sachbeschädigung</b> also lasst es lieber sein.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
4
django_lostplaces/lostplaces/templates/flat_form.html
Normal file
4
django_lostplaces/lostplaces/templates/flat_form.html
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<form method={{form.method}}>
|
||||||
|
{{form}}
|
||||||
|
<input type="submit"/>
|
||||||
|
</form>
|
@ -1,5 +1,6 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load lostplaces%}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -11,6 +12,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="{% static 'main.css' %}">
|
<link rel="stylesheet" href="{% static 'main.css' %}">
|
||||||
|
<link rel="stylesheet" href="{% static 'materialdesignicons.css' %}">
|
||||||
<link rel="icon" type="image/png" href="{% static 'favicon.ico' %}">
|
<link rel="icon" type="image/png" href="{% static 'favicon.ico' %}">
|
||||||
<title>
|
<title>
|
||||||
{% block title %}Urban Exploration{% endblock %}
|
{% block title %}Urban Exploration{% endblock %}
|
||||||
@ -29,16 +31,16 @@
|
|||||||
<span class="LP-Paragraph">
|
<span class="LP-Paragraph">
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
Hi {{ user.username }}!
|
Hi {{ user.username }}!
|
||||||
<a class="LP-Link" href="{% url 'logout' %}"><span class="LP-Link__Text">{% trans 'Logout' %}</span></a> |
|
<a class="LP-Link" href="{% url 'logout' %}"><span class="LP-Link__Text">{% translate 'Logout' %}</span></a> |
|
||||||
<a class="LP-Link" href="{% url 'explorer_profile' explorer_id=user.pk%}"><span class="LP-Link__Text">{% trans 'Profile' %}</span></a>
|
<a class="LP-Link" href="{% url 'explorer_profile' explorer_id=user.pk%}"><span class="LP-Link__Text">{% translate 'Profile' %}</span></a>
|
||||||
{% if user.is_superuser %}
|
{% if user.is_superuser %}
|
||||||
| <a class="LP-Link" href="{% url 'admin:index' %}" target="_blank"><span class="LP-Link__Text">{% trans 'Admin' %}</span></a>
|
| <a class="LP-Link" href="{% url 'admin:index' %}" target="_blank"><span class="LP-Link__Text">{% translate 'Admin' %}</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
You are not logged in.
|
You are not logged in.
|
||||||
<a class="LP-Link" href="{% url 'login' %}"><span class="LP-Link__Text">{% trans 'Login' %}</span></a> |
|
<a class="LP-Link" href="{% url 'login' %}"><span class="LP-Link__Text">{% translate 'Login' %}</span></a> |
|
||||||
<a class="LP-Link" href="{% url 'signup' %}"><span class="LP-Link__Text">{% trans 'Sign up' %}</span></a>
|
<a class="LP-Link" href="{% url 'signup' %}"><span class="LP-Link__Text">{% translate 'Sign up' %}</span></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -48,14 +50,14 @@
|
|||||||
<aside class="LP-Main__Sidebar">
|
<aside class="LP-Main__Sidebar">
|
||||||
<nav class="LP-Menu LP-Menu--sidebar">
|
<nav class="LP-Menu LP-Menu--sidebar">
|
||||||
<ul class="LP-Menu__List">
|
<ul class="LP-Menu__List">
|
||||||
<li class="LP-Menu__Item"><a href="{% url 'lostplaces_home' %}" class="LP-Link"><span class="LP-Link__Text">{% trans 'Home' %}</span></a></li>
|
<li class="LP-Menu__Item"><a href="{% url 'lostplaces_home' %}" class="LP-Link"><span class="LP-Link__Text">{% translate 'Home' %}</span></a></li>
|
||||||
<li class="LP-Menu__Item"><a href="{% url 'flatpage' slug='codex' %}" class="LP-Link"><span class="LP-Link__Text">{% trans 'UrBex Codex' %}</span></a></li>
|
<li class="LP-Menu__Item"><a href="{% url 'flatpage' slug='codex' %}" class="LP-Link"><span class="LP-Link__Text">{% translate 'UrBex Codex' %}</span></a></li>
|
||||||
<li class="LP-Menu__Item"><a href="{% url 'osm' %}" class="LP-Link"><span class="LP-Link__Text">{% trans 'Map' %}</span></a></li>
|
|
||||||
{% block additional_menu_items %}
|
{% block additional_menu_items %}
|
||||||
{% endblock additional_menu_items %}
|
{% endblock additional_menu_items %}
|
||||||
|
|
||||||
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_create'%}" class="LP-Link"><span class="LP-Link__Text">{% trans 'Create place' %}</span></a></li>
|
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_create'%}" class="LP-Link"><span class="LP-Link__Text">{% translate 'Create place' %}</span></a></li>
|
||||||
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_list'%}" class="LP-Link"><span class="LP-Link__Text">{% trans 'All places' %}</span></a></li>
|
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_list'%}" class="LP-Link"><span class="LP-Link__Text">{% translate 'All places' %}</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
@ -87,7 +89,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block footer %}
|
{% block footer %}
|
||||||
{% include 'partials/nav/footer.html' %}
|
{% partial 'nav/footer' %}
|
||||||
{% endblock footer %}
|
{% endblock footer %}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -2,22 +2,25 @@
|
|||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load lostplaces %}
|
||||||
{% block additional_head %}
|
{% block additional_head %}
|
||||||
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
||||||
<script src="{% static 'maps/ol.js' %}"></script>
|
<script src="{% static 'maps/ol.js' %}"></script>
|
||||||
{% endblock additional_head %}
|
{% endblock additional_head %}
|
||||||
|
|
||||||
# {% block title %}{% trans 'Home' %}{% endblock %}
|
# {% block title %}{% translate 'Home' %}{% endblock %}
|
||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
|
|
||||||
{% include 'partials/welcome.html' %}
|
{% partial 'welcome' %}
|
||||||
<article class="LP-TextSection">
|
<article class="LP-TextSection">
|
||||||
</article>
|
</article>
|
||||||
|
{% partial 'osm_map' %}
|
||||||
{% include 'partials/osm_map.html' with config=mapping_config modifier='wide' %}
|
{% set config mapping_config %}
|
||||||
|
{% set modifier 'wide' %}
|
||||||
|
{% endpartial %}
|
||||||
<div class="LP-PlaceGrid">
|
<div class="LP-PlaceGrid">
|
||||||
<h1 class="LP-Headline LP-Headline">{% trans 'Explore the latest places' %}</h1>
|
<h1 class="LP-Headline LP-Headline">{% translate 'Explore the latest places' %}</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">
|
||||||
@ -26,5 +29,4 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
@ -1,30 +1,33 @@
|
|||||||
{% extends 'global.html'%}
|
{% extends 'global.html'%}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load lostplaces%}
|
||||||
|
|
||||||
# {% block title %}Start{% endblock %}
|
# {% block title %}Start{% endblock %}
|
||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
|
|
||||||
{% include 'partials/welcome.html' %}
|
{% partial 'welcome' %}
|
||||||
<article class="LP-TextSection">
|
<article class="LP-TextSection">
|
||||||
<p class="LP-Paragraph">
|
<p class="LP-Paragraph">
|
||||||
{% blocktrans %}You can create, view and share your lost places with other members of this site. You can upload photos, place links to your web galleries and contribute your knowledge by tagging other places or commenting on them. You will find detailed information on where these locations are, how to get there and what to expect from them. This might even include detailed information on the surroundings or the history of a lost place.{% endblocktrans %}
|
{% blocktranslate %}You can create, view and share your lost places with other members of this site. You can upload photos, place links to your web galleries and contribute your knowledge by tagging other places or commenting on them. You will find detailed information on where these locations are, how to get there and what to expect from them. This might even include detailed information on the surroundings or the history of a lost place.{% endblocktranslate %}
|
||||||
</p>
|
</p>
|
||||||
{% url 'signup' as signup_url %}
|
{% url 'signup' as signup_url %}
|
||||||
<p class="LP-Paragraph">
|
<p class="LP-Paragraph">
|
||||||
{% blocktrans %}Since vandalism is a growing problem these days, no sensitive information is available to the public. You have to <a class="LP-Link" href="{{signup_url}}"><span class="LP-Link__Text">sign up</span></a> with a voucher code as an invitation to join this community. Only admins can create these codes. Usually you are given a code when we know you in real life in person and when we trust you. A request from an unknown person will most probably be denied.{% endblocktrans %}
|
{% blocktranslate %}Since vandalism is a growing problem these days, no sensitive information is available to the public. You have to <a class="LP-Link" href="{{signup_url}}"><span class="LP-Link__Text">sign up</span></a> with a voucher code as an invitation to join this community. Only admins can create these codes. Usually you are given a code when we know you in real life in person and when we trust you. A request from an unknown person will most probably be denied.{% endblocktranslate %}
|
||||||
</p>
|
</p>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<div class="LP-PlaceGrid">
|
<div class="LP-PlaceGrid">
|
||||||
<h1 class="LP-Headline LP-Headline">{% trans 'Explore the latest places' %}</h1>
|
<h1 class="LP-Headline LP-Headline">{% translate 'Explore the latest places' %}</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">
|
||||||
<div class="LP-PlaceTeaser__Image">
|
<div class="LP-PlaceTeaser__Image">
|
||||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
{% partial 'image' %}
|
||||||
|
{% set source_url place.placeimages.first.filename.thumbnail.url %}
|
||||||
|
{% endpartial %}
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-PlaceTeaser__Meta">
|
<div class="LP-PlaceTeaser__Meta">
|
||||||
<div class="LP-PlaceTeaser__Info">
|
<div class="LP-PlaceTeaser__Info">
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
<div class="LP-Input {% if classes%}{{classes}}{% endif %} {% if field.errors %} LP-Input--error {% endif %}">
|
<div class="LP-Input {% if classes%}{{classes}}{% endif %} {% 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>
|
||||||
{% with class="LP-Input__Field "%}
|
{% render_field field class+='LP-Input__Field' %}
|
||||||
{% render_field field class=class%}
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
<span class="LP-Input__Message">
|
<span class="LP-Input__Message">
|
||||||
{% if field.errors %}
|
{% if field.errors %}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
||||||
<button class="LP-Button">{% if action %}{{ action }}{% else %}{% trans 'Submit' %}{% endif %}</button>
|
<button class="LP-Button">{% if action %}{{ action }}{% else %}{% translate 'Submit' %}{% endif %}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
||||||
<a class="LP-Link" href="{% if referer %}{{ referer }}{% else %}{% url 'lostplaces_home' %}{% endif %}">
|
<a class="LP-Link" href="{% if referer %}{{ referer }}{% else %}{% url 'lostplaces_home' %}{% endif %}">
|
||||||
<button type="button" class="LP-Button LP-Button--cancel">{% trans 'Cancel' %}</button>
|
<button type="button" class="LP-Button LP-Button--cancel">{% translate 'Cancel' %}</button>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
18
django_lostplaces/lostplaces/templates/partials/image.html
Normal file
18
django_lostplaces/lostplaces/templates/partials/image.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{% if link_url %}
|
||||||
|
<a
|
||||||
|
class="LP-Link"
|
||||||
|
href="{{link_url}}"
|
||||||
|
>
|
||||||
|
{% endif %}
|
||||||
|
<figure class="LP-Figure">
|
||||||
|
<img
|
||||||
|
src="{{ source_url }}"
|
||||||
|
{% if alt_text %}
|
||||||
|
alt="{{alt_text}}"
|
||||||
|
{% else %}
|
||||||
|
alt="{{block}}"
|
||||||
|
{% endif %}
|
||||||
|
class="LP-Image"
|
||||||
|
/>
|
||||||
|
</figure>
|
||||||
|
{% if link_url %}</a>{% endif %}
|
@ -61,13 +61,13 @@
|
|||||||
<!-- Bottom section with last line of text and links. -->
|
<!-- Bottom section with last line of text and links. -->
|
||||||
<section class="LP-Footer__BottomSection LP-Footer__Flex">
|
<section class="LP-Footer__BottomSection LP-Footer__Flex">
|
||||||
<div class="LP-Footer__BottomWrapper">
|
<div class="LP-Footer__BottomWrapper">
|
||||||
{% trans 'Made by' %} <a href="https://git.mowoe.com/reverend" class="LP-Footer__GenericAnchor">Reverend</a>
|
{% translate 'Made by' %} <a href="https://git.mowoe.com/reverend" class="LP-Footer__GenericAnchor">Reverend</a>
|
||||||
{% trans 'and' %} <a href="https://www.commander1024.de" class="LP-Footer__GenericAnchor">Commander1024.</a></span>
|
{% translate 'and' %} <a href="https://www.commander1024.de" class="LP-Footer__GenericAnchor">Commander1024.</a></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Footer__BottomWrapper">
|
<div class="LP-Footer__BottomWrapper">
|
||||||
<a href="{% url 'flatpage' slug='privacy-policy' %}" class="LP-Footer__GenericAnchor">{% trans 'Privacy Policy' %}</a>
|
<a href="{% url 'flatpage' slug='privacy-policy' %}" class="LP-Footer__GenericAnchor">{% translate 'Privacy Policy' %}</a>
|
||||||
|
|
|
|
||||||
<a href="{% url 'flatpage' slug='imprint' %}" class="LP-Footer__GenericAnchor">{% trans 'Imprint' %}</a>
|
<a href="{% url 'flatpage' slug='imprint' %}" class="LP-Footer__GenericAnchor">{% translate 'Imprint' %}</a>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -8,26 +8,26 @@
|
|||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--first">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--first">
|
||||||
<a href="?page=1" class="LP-Link">
|
<a href="?page=1" class="LP-Link">
|
||||||
<span class="LP-Icon">⟪</span>
|
<span class="LP-Icon">⟪</span>
|
||||||
<span class="LP-Text">{% trans 'First' %}</span>
|
<span class="LP-Text">{% translate 'First' %}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--previous">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--previous">
|
||||||
<a href="?page={{ page_obj.previous_page_number }}" class="LP-Link">
|
<a href="?page={{ page_obj.previous_page_number }}" class="LP-Link">
|
||||||
<span class="LP-Icon">⟨</span>
|
<span class="LP-Icon">⟨</span>
|
||||||
<span class="LP-Text">{% trans 'Previous' %}</span>
|
<span class="LP-Text">{% translate 'Previous' %}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--first LP-Pagination__Item--disabled">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--first LP-Pagination__Item--disabled">
|
||||||
<a href="#" class="LP-Link">
|
<a href="#" class="LP-Link">
|
||||||
<span class="LP-Icon">⟪</span>
|
<span class="LP-Icon">⟪</span>
|
||||||
<span class="LP-Text">{% trans 'First' %}</span>
|
<span class="LP-Text">{% translate 'First' %}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--previous LP-Pagination__Item--disabled">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--previous LP-Pagination__Item--disabled">
|
||||||
<a href="#" class="LP-Link">
|
<a href="#" class="LP-Link">
|
||||||
<span class="LP-Icon">⟨</span>
|
<span class="LP-Icon">⟨</span>
|
||||||
<span class="LP-Text">{% trans 'Previous' %}</span>
|
<span class="LP-Text">{% translate 'Previous' %}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -47,25 +47,25 @@
|
|||||||
{% if page_obj.has_next %}
|
{% if page_obj.has_next %}
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--next">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--next">
|
||||||
<a href="?page={{ page_obj.next_page_number }}" class="LP-Link">
|
<a href="?page={{ page_obj.next_page_number }}" class="LP-Link">
|
||||||
<span class="LP-Text">{% trans 'Next' %}</span>
|
<span class="LP-Text">{% translate 'Next' %}</span>
|
||||||
<span class="LP-Icon">⟩</span>
|
<span class="LP-Icon">⟩</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--last">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--last">
|
||||||
<a href="?page={{ page_obj.paginator.num_pages }}" class="LP-Link">
|
<a href="?page={{ page_obj.paginator.num_pages }}" class="LP-Link">
|
||||||
<span class="LP-Text">{% trans 'Last' %}</span>
|
<span class="LP-Text">{% translate 'Last' %}</span>
|
||||||
<span class="LP-Icon">⟫</span>
|
<span class="LP-Icon">⟫</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--next LP-Pagination__Item--disabled">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--next LP-Pagination__Item--disabled">
|
||||||
<a href="#" class="LP-Link">
|
<a href="#" class="LP-Link">
|
||||||
<span class="LP-Text">{% trans 'Next' %}</span>
|
<span class="LP-Text">{% translate 'Next' %}</span>
|
||||||
<span class="LP-Icon">⟩</span>
|
<span class="LP-Icon">⟩</span>
|
||||||
</a>
|
</a>
|
||||||
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--last LP-Pagination__Item--disabled">
|
<li class="LP-Pagination__Item LP-Pagination__Item--other LP-Pagination__Item--last LP-Pagination__Item--disabled">
|
||||||
<a href="#" class="LP-Link">
|
<a href="#" class="LP-Link">
|
||||||
<span class="LP-Text">{% trans 'Last' %}</span>
|
<span class="LP-Text">{% translate 'Last' %}</span>
|
||||||
<span class="LP-Icon">⟫</span>
|
<span class="LP-Icon">⟫</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
{% load static %}
|
||||||
|
{% load lostplaces %}
|
||||||
|
|
||||||
|
{% if headline %}
|
||||||
|
<h1 class="LP-Headline">{{headline}}</h1>
|
||||||
|
{% endif %}
|
||||||
|
<div class="LP-ImageGrid">
|
||||||
|
<ul class="LP-ImageGrid__Container">
|
||||||
|
{% for image in image_list %}
|
||||||
|
<li id="thumbnail{{forloop.counter0}}" class="LP-ImageGrid__Item">
|
||||||
|
{% include 'partials/image.html' with source_url=image.filename.thumbnail.url link_url="#image"|addstr:forloop.counter0 %}
|
||||||
|
{% if user.explorer == image.submitted_by%}
|
||||||
|
<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
|
||||||
|
<a href="{% url 'place_image_delete' pk=image.id %}" class="LP-Link">
|
||||||
|
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}" />
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
<div id="image{{forloop.counter0}}" class="LP-ImageGrid__LightBox">
|
||||||
|
<img class="LP-ImageGrid__FullSizeImage" src="{{image.filename.large.url}}" loading="lazy"/>
|
||||||
|
{% if forloop.counter0 < image_list|length|add:-1 %}
|
||||||
|
<a href="#image{{forloop.counter0|add:1}}" class="LP-ImageGrid__Next">Next</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if forloop.counter0 > 0 %}
|
||||||
|
<a href="#image{{forloop.counter0|add:-1}}" class="LP-ImageGrid__Previous">Previous</a>
|
||||||
|
{% endif %}
|
||||||
|
<span class="LP-ImageGrid__Close LP-ImageGrid__DeleteItem" title="Schließen">
|
||||||
|
<a href="#thumbnail{{forloop.counter0}}" class="LP-Link">
|
||||||
|
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}"/>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
{% if place %}
|
||||||
|
<li class="LP-ImageGrid__Item LP-ImageGrid__Item--add" title="Bild hinzufügen">
|
||||||
|
<a class="LP-Link" href="{% url 'place_image_create' place_id=place.id %}">
|
||||||
|
<img class="LP-Icon" src="{% static 'icons/plus.svg' %}" />
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
@ -1,12 +1,13 @@
|
|||||||
{%load static %}
|
{%load static %}
|
||||||
|
|
||||||
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
||||||
<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
|
|
||||||
<div class="LP-PlaceTeaser__Image">
|
<div class="LP-PlaceTeaser__Image">
|
||||||
{% if place.placeimages.all|length > 0 %}
|
{% if place.get_hero_image %}
|
||||||
<img class="LP-Image" src="{{ place.placeimages.first.filename.thumbnail.url}}" />
|
{% include 'partials/image.html' with source_url=place.get_hero_image.filename.thumbnail.url link_url=place.get_absolute_url%}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<a href="{{place.get_absolute_url}}">
|
||||||
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
|
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
{%load lostplaces %}
|
||||||
|
|
||||||
|
{% include 'partials/image.html' with source_url=object.filename.thumbnail.url %}
|
@ -25,13 +25,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{% url config.submit_url_name tagged_id=config.tagged_item.id%}">
|
<form id="id_tag_submit_form" class="LP-Form LP-Form--inline LP-Form--tagging" method="POST" action="{{config.submit_url}}">
|
||||||
<fieldset class="LP-Form__Fieldset">
|
<fieldset class="LP-Form__Fieldset">
|
||||||
<legend class="LP-Form__Legend">{% trans 'Add tags' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Add tags' %}</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 LP-Form__Button LP-Input LP-Input--tagging">
|
<div class="LP-Form__Field LP-Form__Button LP-Input LP-Input--tagging">
|
||||||
<button id="id_tag_submit_button" class="LP-Button">{% trans 'Add tags' %}</button>
|
<button id="id_tag_submit_button" class="LP-Button">{% translate 'Add tags' %}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
{% include 'partials/form/inputField.html' with field=config.submit_form.tag_list classes="LP-Input--tagging" %}
|
{% include 'partials/form/inputField.html' with field=config.submit_form.tag_list classes="LP-Input--tagging" %}
|
||||||
|
41
django_lostplaces/lostplaces/templates/partials/voting.html
Normal file
41
django_lostplaces/lostplaces/templates/partials/voting.html
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<div class="LP-Voting">
|
||||||
|
<div class="LP-Voting__Left">
|
||||||
|
<h2 class="LP-Headline">
|
||||||
|
Place level
|
||||||
|
</h2>
|
||||||
|
<div class="LP-Voting__Choices">
|
||||||
|
{% for choice in voting.all_choices %}
|
||||||
|
<a href="{% url 'place_vote' place_id=place.id vote=choice.0 %}" class="LP-Voting__Vote {% if choice.0 <= place.level %} LP-Voting__Vote--overall{% endif %}" title="Vote place as "{{choice.1}}"">
|
||||||
|
<i class="mdi mdi-shield-home"></i>
|
||||||
|
<span class="LP-Voting__Label">
|
||||||
|
{{choice.1}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="LP-Voting__CurrentVote">
|
||||||
|
{{place.get_level_display}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if voting.users_vote %}
|
||||||
|
<div class="LP-Voting__Right">
|
||||||
|
<div class="LP-Voting__Info">
|
||||||
|
<div class="LP-Voting__UserVote">
|
||||||
|
<span class="LP-Voting__InfoLabel">You voted this place as</span>
|
||||||
|
<span class="LP-Voting__Vote">{{voting.users_vote.get_human_readable_level}} <i>Level {{voting.users_vote.vote}}</i></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="LP-Voting__Expiration">
|
||||||
|
<span class="LP-Voting__InfoLabel">Your vote expires on</span>
|
||||||
|
<span class="LP-Voting__Date">
|
||||||
|
<time datetime="{{voting.expires_when|date:'Y-m-d'}}">
|
||||||
|
{{voting.users_vote.expires_when|date:'d.m.Y'}}
|
||||||
|
</time>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
@ -1,21 +1,21 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
<header class="LP-TextSection__Headline">
|
<header class="LP-TextSection__Headline">
|
||||||
<h1 class="LP-Headline">{% trans 'Start' %}</h1>
|
<h1 class="LP-Headline">{% translate 'Start' %}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="LP-TextSection__Text">
|
<div class="LP-TextSection__Text">
|
||||||
<p class="LP-Paragraph">{% trans 'Welcome to our Urban Exploration community catalogue,' %}
|
<p class="LP-Paragraph">{% translate 'Welcome to our Urban Exploration community catalogue,' %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
{{ user.username }}
|
{{ user.username }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% trans 'explorer' %}
|
{% translate 'explorer' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
!
|
!
|
||||||
</p>
|
</p>
|
||||||
<p class="LP-Paragraph">
|
<p class="LP-Paragraph">
|
||||||
{% trans 'We strictly follow our' %}
|
{% translate 'We strictly follow our' %}
|
||||||
<a class="LP-Link" href="{% url 'flatpage' slug='codex' %}"><span class="LP-Link__Text">{% trans 'UrBex codex' %}</span></a>
|
<a class="LP-Link" href="{% url 'flatpage' slug='codex' %}"><span class="LP-Link__Text">{% translate 'UrBex codex' %}</span></a>
|
||||||
{% trans 'and expect you to do so, too.' %}'
|
{% translate 'and expect you to do so, too.' %}'
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
{% extends 'global.html'%}
|
{% extends 'global.html'%}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Submit a photo album' %}{% endblock %}
|
{% block title %}{% translate 'Submit a photo album' %}{% endblock %}
|
||||||
|
|
||||||
{% block additional_menu_items %}
|
{% block additional_menu_items %}
|
||||||
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_edit' pk=place.pk %}" class="LP-Link"><span
|
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_edit' pk=place.pk %}" class="LP-Link"><span
|
||||||
class="LP-Link__Text">{% trans 'Edit place' %}</span></a></li>
|
class="LP-Link__Text">{% translate 'Edit place' %}</span></a></li>
|
||||||
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_delete' pk=place.pk %}" class="LP-Link"><span
|
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_delete' pk=place.pk %}" class="LP-Link"><span
|
||||||
class="LP-Link__Text">{% trans 'Delete place' %}</span></a></li>
|
class="LP-Link__Text">{% translate 'Delete place' %}</span></a></li>
|
||||||
{% endblock additional_menu_items %}
|
{% endblock additional_menu_items %}
|
||||||
|
|
||||||
{% 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">{% trans 'Submit a photo album for' %} {{place.name}}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Submit a photo album for' %} {{place.name}}</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field">
|
<div class="LP-Form__Field">
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
# {% block title %}{% trans 'Create place' %}{% endblock %}
|
# {% block title %}{% translate 'Create place' %}{% endblock %}
|
||||||
|
|
||||||
{% 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">{% trans 'Create place' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Create place' %}</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">
|
||||||
@ -39,7 +39,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% trans 'Create' as action %}
|
{% translate 'Create' as action %}
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
||||||
{% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
|
{% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,21 +2,21 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Delete lost place' %}{% endblock %}
|
{% block title %}{% translate 'Delete lost place' %}{% endblock %}
|
||||||
|
|
||||||
{% 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">{% trans 'Delete place' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Delete place' %}</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
<div class="LP-Form__Field LP-Form__InfoText">
|
<div class="LP-Form__Field LP-Form__InfoText">
|
||||||
<p class="LP-Paragraph">{% blocktrans with place_name=place.name%}Are you sure you want to delete {{place_name}}?{% endblocktrans %}</p>
|
<p class="LP-Paragraph">{% blocktranslate with place_name=place.name%}Are you sure you want to delete {{place_name}}?{% endblocktranslate %}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% trans 'Delete' as action %}
|
{% translate 'Delete' as action %}
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
||||||
{% include 'partials/form/submit.html' with referer=request.META.HTTP_REFERER action=action %}
|
{% include 'partials/form/submit.html' with referer=request.META.HTTP_REFERER action=action %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
{% load thumbnail %}
|
{% load thumbnail %}
|
||||||
{% load svg_icon %}
|
{% load svg_icon %}
|
||||||
|
{% load lostplaces %}
|
||||||
|
|
||||||
{% block additional_head %}
|
{% block additional_head %}
|
||||||
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
|
||||||
@ -15,19 +16,23 @@
|
|||||||
{% block title %}{{place.name}}{% endblock %}
|
{% block title %}{{place.name}}{% endblock %}
|
||||||
|
|
||||||
{% block additional_menu_items %}
|
{% block additional_menu_items %}
|
||||||
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_edit' pk=place.pk %}" class="LP-Link"><span class="LP-Link__Text">{% trans 'Edit place' %}</span></a></li>
|
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_edit' pk=place.pk %}" class="LP-Link"><span class="LP-Link__Text">{% translate 'Edit place' %}</span></a></li>
|
||||||
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_delete' pk=place.pk %}" class="LP-Link"><span class="LP-Link__Text">{% trans 'Delete place' %}</span></a></li>
|
<li class="LP-Menu__Item LP-Menu__Item--additional"><a href="{% url 'place_delete' pk=place.pk %}" class="LP-Link"><span class="LP-Link__Text">{% translate 'Delete place' %}</span></a></li>
|
||||||
{% endblock additional_menu_items %}
|
{% endblock additional_menu_items %}
|
||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<article class="LP-PlaceDetail">
|
<article class="LP-PlaceDetail">
|
||||||
|
|
||||||
<header class="LP-PlaceDetail__Header">
|
<header class="LP-PlaceDetail__Header">
|
||||||
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %} {% include 'partials/icons/place_visited.html' %}</h1>
|
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %} {% include 'partials/icons/place_visited.html' %}</h1>
|
||||||
{% if place.placeimages.first.filename.hero.url %}
|
{% if place.get_hero_image %}
|
||||||
<figure class="LP-PlaceDetail__Image">
|
<div class="LP-PlaceDetail__Image">
|
||||||
<img src="{{ place.placeimages.first.filename.hero.url }}" class="LP-Image" />
|
{% partial image %}
|
||||||
</figure>
|
{% set source_url place.get_hero_image.filename.hero.url %}
|
||||||
|
{% set link_url %}
|
||||||
|
{{"#image"|addstr:place.get_hero_index_in_queryset}}
|
||||||
|
{% endset %}
|
||||||
|
{% endpartial %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@ -35,27 +40,68 @@
|
|||||||
<p class="LP-Paragraph">{{ place.description }}</p>
|
<p class="LP-Paragraph">{{ place.description }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="LP-Quickinfo">
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
|
{% url 'place_tag_submit' place_id=place.id as tag_submit_url %}
|
||||||
{% url 'place_tag_submit' place_id=place.id as tag_submit_url%}
|
{% partial tagging %}
|
||||||
{% include 'partials/tagging.html' with config=tagging_config %}
|
{% set config=tagging_config %}
|
||||||
|
{% endpartial %}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
{{votingplace.vote}}
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Map links' %}</h1>
|
{% partial voting %}
|
||||||
{% include 'partials/osm_map.html' with config=mapping_config modifier='wide' %}
|
{% set place=place %}
|
||||||
<div class="LP-LinkList">
|
{% set voting=placevoting %}
|
||||||
<ul class="LP-LinkList__Container">
|
{% endpartial %}
|
||||||
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.google.com/maps?q={{place.latitude|safe}},{{place.longitude|safe}}" class="LP-Link"><span class="LP-Text">Google Maps</span></a></li>
|
</section>
|
||||||
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.tim-online.nrw.de/tim-online2/?center={{place.latitude|safe}},{{place.longitude|safe}}&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|safe}}&mlon={{place.longitude|safe}}&zoom=16" class="LP-Link"><span class="LP-Text">OSM</span></a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<section class="LP-Section">
|
||||||
|
<h1 class="LP-Headline">{% translate 'Map links' %}</h1>
|
||||||
|
{% partial osm_map config=mapping_config %}
|
||||||
|
<ul class="LP-LinkList">
|
||||||
|
<li class="LP-LinkList__Item">
|
||||||
|
<a target="_blank" href="https://www.google.com/maps?q={{place.latitude|safe}},{{place.longitude|safe}}" class="LP-Link">
|
||||||
|
<span class="LP-Text RV-Iconized">
|
||||||
|
<span class="RV-Iconized__Text">
|
||||||
|
Google Maps
|
||||||
|
</span>
|
||||||
|
<span class="RV-Iconized__Icon RV-Iconized__Icon--left">
|
||||||
|
<i class="mdi mdi-map-outline"></i>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="LP-LinkList__Item">
|
||||||
|
<a target="_blank" href="https://www.tim-online.nrw.de/tim-online2/?center={{place.latitude|safe}},{{place.longitude|safe}}&icon=true&bg=dop" class="LP-Link">
|
||||||
|
<span class="LP-Text RV-Iconized">
|
||||||
|
<span class="RV-Iconized__Text">
|
||||||
|
TIM Online
|
||||||
|
</span>
|
||||||
|
<span class="RV-Iconized__Icon RV-Iconized__Icon--left">
|
||||||
|
<i class="mdi mdi-map-outline"></i>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="LP-LinkList__Item">
|
||||||
|
<a target="_blank" href="http://www.openstreetmap.org/?mlat={{place.latitude|safe}}&mlon={{place.longitude|safe}}&zoom=16" class="LP-Link">
|
||||||
|
<span class="LP-Text RV-Iconized">
|
||||||
|
<span class="RV-Iconized__Text">
|
||||||
|
OSM
|
||||||
|
</span>
|
||||||
|
<span class="RV-Iconized__Icon RV-Iconized__Icon--left">
|
||||||
|
<i class="mdi mdi-map-outline"></i>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class=" LP-Section">
|
<section class=" LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Photo albums' %}</h1>
|
<h1 class="LP-Headline">{% translate 'Photo albums' %}</h1>
|
||||||
<div class="LP-LinkList">
|
<div class="LP-LinkList">
|
||||||
<ul class="LP-LinkList__Container">
|
<ul class="LP-LinkList__Container">
|
||||||
{% for photo_album in place.photoalbums.all %}
|
{% for photo_album in place.photoalbums.all %}
|
||||||
@ -81,7 +127,7 @@
|
|||||||
v216c0,11.046,8.954,20,20,20s20-8.954,20-20V276h216c11.046,0,20-8.954,20-20C512,244.954,503.046,236,492,236z" />
|
v216c0,11.046,8.954,20,20,20s20-8.954,20-20V276h216c11.046,0,20-8.954,20-20C512,244.954,503.046,236,492,236z" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
<span class="RV-Iconized__Text">{% trans 'Add photo album' %}</span>
|
<span class="RV-Iconized__Text">{% translate 'Add photo album' %}</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -90,30 +136,8 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="LP-Section">
|
<section class="LP-Section">
|
||||||
<h1 class="LP-Headline">{% trans 'Images' %}</h1>
|
{% translate 'Images' as headline %}
|
||||||
<div class="LP-ImageGrid">
|
{% partial "placeImageGrid" image_list=place.placeimages.all %}
|
||||||
<ul class="LP-ImageGrid__Container">
|
|
||||||
{% for place_image in place.placeimages.all %}
|
|
||||||
<li class="LP-ImageGrid__Item">
|
|
||||||
<a href="{{ place_image.filename.large.url }}" class="LP-Link">
|
|
||||||
<img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}">
|
|
||||||
</a>
|
|
||||||
{% if user.explorer == place_image.submitted_by or user.explorer == place.submitted_by %}
|
|
||||||
<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
|
|
||||||
<a href="{% url 'place_image_delete' pk=place_image.id %}" class="LP-Link">
|
|
||||||
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}" />
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
<li class="LP-ImageGrid__Item LP-ImageGrid__Item--add" title="Bild hinzufügen">
|
|
||||||
<a class="LP-Link" href="{% url 'place_image_create' place_id=place.id%}">
|
|
||||||
<img class="LP-Icon" src="{% static 'icons/plus.svg' %}" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</article>
|
</article>
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
<script src="{% static 'maps/ol.js' %}"></script>
|
<script src="{% static 'maps/ol.js' %}"></script>
|
||||||
{% endblock additional_head %}
|
{% endblock additional_head %}
|
||||||
|
|
||||||
{% block title %}{% trans 'All Places' %}{% endblock %}
|
{% block title %}{% translate 'All Places' %}{% endblock %}
|
||||||
|
|
||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
|
|
||||||
{% include 'partials/osm_map.html' with config=mapping_config modifier='wide' %}
|
{% include 'partials/osm_map.html' with config=mapping_config modifier='wide' %}
|
||||||
<div class="LP-PlaceList">
|
<div class="LP-PlaceList">
|
||||||
<h1 class="LP-Headline">{% trans 'Our lost places' %}</h1>
|
<h1 class="LP-Headline">{% translate 'Our lost places' %}</h1>
|
||||||
<ul class="LP-PlaceList__List">
|
<ul class="LP-PlaceList__List">
|
||||||
{% for place in place_list %}
|
{% for place in place_list %}
|
||||||
<li class="LP-PlaceList__Item">
|
<li class="LP-PlaceList__Item">
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
{% extends 'global.html'%}
|
{% extends 'global.html'%}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
# {% block title %}{% trans 'Edit place' %}{% endblock %}
|
# {% block title %}{% translate 'Edit place' %}{% endblock %}
|
||||||
|
|
||||||
{% 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">{% trans 'Edit place' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Edit place' %}</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">
|
||||||
@ -39,7 +40,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% trans 'Update' as action %}
|
{% if object.placeimages.all|length > 0 %}
|
||||||
|
<legend class="LP-Form__Legend">{% translate 'Set Hero Image' %}</legend>
|
||||||
|
<div class="LP-Form__Composition">
|
||||||
|
<div class="LP-Form__Field">
|
||||||
|
{% render_field form.hero container_class='LP-ImageGrid__Container' item_class='LP-ImageGrid__Item LP-Select' current_selected_value=object.hero.id%}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% translate 'Update' as action %}
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
||||||
{% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
|
{% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{% 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">{% trans 'Submit images to a place' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Submit images to a place' %}</legend>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="LP-Form__Composition">
|
<div class="LP-Form__Composition">
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{% extends 'global.html'%}
|
{% extends 'global.html'%}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
# {% block title %}{% trans 'Login' %}{% endblock %}
|
# {% block title %}{% translate 'Login' %}{% endblock %}
|
||||||
|
|
||||||
{% 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">{% trans 'Login' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Login' %}</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">
|
||||||
@ -20,12 +20,12 @@
|
|||||||
|
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
||||||
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
||||||
<button class="LP-Button">{% trans 'Login' %}</button>
|
<button class="LP-Button">{% translate 'Login' %}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p class="LP-Headline">{% trans 'No account, yet?' %} <a class="LP-Link" href="{% url 'signup' %}"><span class="LP-Link__Text">{% trans 'Sign up' %}</span></a></p>
|
<p class="LP-Headline">{% translate 'No account, yet?' %} <a class="LP-Link" href="{% url 'signup' %}"><span class="LP-Link__Text">{% translate 'Sign up' %}</span></a></p>
|
||||||
|
|
||||||
{% endblock maincontent %}
|
{% endblock maincontent %}
|
@ -3,13 +3,13 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
# {% block title %}{% trans 'Sign up' %}{% endblock %}
|
# {% block title %}{% translate 'Sign up' %}{% endblock %}
|
||||||
|
|
||||||
{% 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">{% trans 'Sign up' %}</legend>
|
<legend class="LP-Form__Legend">{% translate 'Sign up' %}</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">
|
||||||
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
||||||
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
<div class="LP-Form__Field LP-Form__Button LP-Input">
|
||||||
<button class="LP-Button">{% trans 'Sign up' %}</button>
|
<button class="LP-Button">{% translate 'Sign up' %}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
<ul class="{{widget.attrs.container_class}}">
|
||||||
|
{% for group_name, group_choices, group_index in widget.optgroups %}
|
||||||
|
{% for option in group_choices %}
|
||||||
|
{% if option.value %}
|
||||||
|
<li style="display: content;">
|
||||||
|
<input
|
||||||
|
style="display: none;"
|
||||||
|
name="{{option.name}}"
|
||||||
|
id="{{widget.attrs.id}}{{group_index}}"
|
||||||
|
type="radio"
|
||||||
|
value="{{option.value.instance.id}}"
|
||||||
|
{% if widget.attrs.current_selected_value|stringformat:'s' == option.value.instance.id|stringformat:'s' %}checked="checked"{% endif %}
|
||||||
|
/>
|
||||||
|
<label class="{{widget.attrs.item_class}}" for="{{widget.attrs.id}}{{group_index}}">
|
||||||
|
{% if widget.attrs.item_template %}
|
||||||
|
{% include widget.attrs.item_template with object=option.value.instance %}
|
||||||
|
{% endif %}
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
@ -6,6 +6,16 @@ from django.http import request
|
|||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
|
def remove_formatting(string):
|
||||||
|
if type(string) is str:
|
||||||
|
for to_strip in ["'", '"', ' ']:
|
||||||
|
string = string.strip(to_strip)
|
||||||
|
|
||||||
|
for to_remove in ['\t', '\n',]:
|
||||||
|
string = string.replace(to_remove, '')
|
||||||
|
|
||||||
|
return string
|
||||||
|
|
||||||
@register.filter(name='proper_paginate')
|
@register.filter(name='proper_paginate')
|
||||||
def proper_paginate(paginator, current_page, neighbors=2):
|
def proper_paginate(paginator, current_page, neighbors=2):
|
||||||
if paginator.num_pages > 2*neighbors:
|
if paginator.num_pages > 2*neighbors:
|
||||||
@ -24,3 +34,97 @@ def proper_paginate(paginator, current_page, neighbors=2):
|
|||||||
page_list = [f for f in range(start_index, end_index+1)]
|
page_list = [f for f in range(start_index, end_index+1)]
|
||||||
return page_list[:(2*neighbors + 1)]
|
return page_list[:(2*neighbors + 1)]
|
||||||
return paginator.page_range
|
return paginator.page_range
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def addstr(value, parameter):
|
||||||
|
return str(value) + str(parameter)
|
||||||
|
|
||||||
|
class VariableNode(template.Node):
|
||||||
|
def __init__(self, name, content=None):
|
||||||
|
if content==None and '=' in name:
|
||||||
|
self.content = name.split('=')[1]
|
||||||
|
self.name = name.split('=')[0]
|
||||||
|
else:
|
||||||
|
self.content = content
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
def render(self, context):
|
||||||
|
if type(self.content) is not str:
|
||||||
|
self.content = self.content.render(context)
|
||||||
|
try:
|
||||||
|
self.content = template.Variable(self.content).resolve(context)
|
||||||
|
except template.VariableDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.content = remove_formatting(self.content)
|
||||||
|
context[self.name] = self.content
|
||||||
|
return ''
|
||||||
|
|
||||||
|
class PartialNode(template.Node):
|
||||||
|
def __init__(self, name, block):
|
||||||
|
self.name = remove_formatting(name)
|
||||||
|
self.block = block
|
||||||
|
|
||||||
|
def render(self, context):
|
||||||
|
if type(self.block) is template.NodeList:
|
||||||
|
self.block = self.block.render(context)
|
||||||
|
|
||||||
|
self.block = remove_formatting(self.block)
|
||||||
|
|
||||||
|
context = context.flatten()
|
||||||
|
context['block'] = self.block
|
||||||
|
t = template.loader.get_template('partials/%s.html' % self.name)
|
||||||
|
return t.render(context)
|
||||||
|
|
||||||
|
@register.tag(name='set')
|
||||||
|
def set_block(parser, token):
|
||||||
|
split = token.split_contents()
|
||||||
|
if len(split) >= 1:
|
||||||
|
variable_name = split[1]
|
||||||
|
else:
|
||||||
|
raise template.TemplateSyntaxError('%r expects a variable name' % split[0])
|
||||||
|
|
||||||
|
if len(split) == 2:
|
||||||
|
content=None
|
||||||
|
if '=' not in variable_name:
|
||||||
|
content = parser.parse(('end%s'%split[0],))
|
||||||
|
parser.delete_first_token()
|
||||||
|
return VariableNode(variable_name, content)
|
||||||
|
else:
|
||||||
|
return VariableNode(variable_name, split[2])
|
||||||
|
|
||||||
|
@register.tag(name='partial')
|
||||||
|
def partial(parser, token):
|
||||||
|
split = token.split_contents()
|
||||||
|
if len(split) >= 1:
|
||||||
|
partial_name = split[1]
|
||||||
|
else:
|
||||||
|
raise template.TemplateSyntaxError('%r expects a partial name' % split[0])
|
||||||
|
|
||||||
|
if len(split) == 2:
|
||||||
|
block_tag = False
|
||||||
|
for token in reversed(parser.tokens):
|
||||||
|
if 'end%s'%split[0] in token.contents:
|
||||||
|
block_tag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if split[0] in token.contents:
|
||||||
|
break
|
||||||
|
|
||||||
|
if block_tag:
|
||||||
|
nodeList = parser.parse(('end%s'%split[0],))
|
||||||
|
parser.delete_first_token()
|
||||||
|
else:
|
||||||
|
nodeList = template.NodeList()
|
||||||
|
return PartialNode(partial_name, nodeList)
|
||||||
|
else:
|
||||||
|
nodeList = template.NodeList()
|
||||||
|
for parameter in split[2:]:
|
||||||
|
if '=' in parameter:
|
||||||
|
nodeList.append(
|
||||||
|
VariableNode(name=parameter)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise template.TemplateSyntaxError('%r expects kwargs, got args' % split[0])
|
||||||
|
return PartialNode(partial_name, nodeList)
|
||||||
|
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import re
|
||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
@ -16,6 +17,20 @@ class ViewTestCase(TestCase):
|
|||||||
'''
|
'''
|
||||||
view = None
|
view = None
|
||||||
|
|
||||||
|
def assertMessage(self, response, message_text, message_type, msg=None):
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""<div.*message.*%s.*>.*%s.*</div>""" % (
|
||||||
|
message_type.lower(),
|
||||||
|
message_text.lower()
|
||||||
|
),
|
||||||
|
response.content.decode().replace('\n', '').lower()
|
||||||
|
),
|
||||||
|
msg
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def assertContext(self, response, key, value=None):
|
def assertContext(self, response, key, value=None):
|
||||||
'''
|
'''
|
||||||
Checks weather the response's context has the given key
|
Checks weather the response's context has the given key
|
||||||
@ -87,7 +102,7 @@ class ViewTestCase(TestCase):
|
|||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
response['location'],
|
response['location'],
|
||||||
redirect_to,
|
redirect_to,
|
||||||
msg='Expecting the response to redirect to %s, where redirected to %s instea' % (
|
msg='Expecting the response to redirect to %s, where redirected to %s instead' % (
|
||||||
str(redirect_to),
|
str(redirect_to),
|
||||||
str(response['location'])
|
str(response['location'])
|
||||||
)
|
)
|
||||||
@ -114,6 +129,84 @@ class ViewTestCase(TestCase):
|
|||||||
def assertHttpMethodNotAllowed(self, response):
|
def assertHttpMethodNotAllowed(self, response):
|
||||||
self.assertHttpCode(response, 405)
|
self.assertHttpCode(response, 405)
|
||||||
|
|
||||||
|
class GlobalTemplateTestCaseMixin:
|
||||||
|
|
||||||
|
def assertGlobal(self, response):
|
||||||
|
self.assertLogo(response)
|
||||||
|
self.assertMenu(response)
|
||||||
|
self.assertProfileMenu(response)
|
||||||
|
|
||||||
|
def assertLogo(self, response):
|
||||||
|
"""
|
||||||
|
Looks for an image tag with with 'logo' or 'Logo' in the file name
|
||||||
|
all within an <header> tag.
|
||||||
|
"""
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""<header.*>.*<img.*src=("|').*(logo|Logo).*("|').*>.*</header>""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg='Expecting a header containing a logo with \'logo\' in the source name'
|
||||||
|
)
|
||||||
|
|
||||||
|
def assertMenu(self, response):
|
||||||
|
"""
|
||||||
|
Looks for an '<nav>' tag containing a link to / and a link labeled 'urbex code.*'
|
||||||
|
"""
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""<nav.*>.*<a.*href=("|')/("|').*>.*<a.*>.*urbex code.*</nav>""",
|
||||||
|
response.content.decode().replace('\n', '').lower()
|
||||||
|
),
|
||||||
|
msg='Expecting an menu containing a link to the homepage and a link to the urbex codex'
|
||||||
|
)
|
||||||
|
|
||||||
|
def assertMenuItem(self, response, label=None, url=None):
|
||||||
|
"""
|
||||||
|
Checks for an additional menu item by label or url. Regex can be passed.
|
||||||
|
"""
|
||||||
|
if label is None and url is None:
|
||||||
|
raise ValueError("Either a label or url has to be provided")
|
||||||
|
|
||||||
|
found_label = None
|
||||||
|
if label != None:
|
||||||
|
label = label.lower()
|
||||||
|
found_label = re.search(
|
||||||
|
"""<nav.*>.*<a.*>.*%s.*</a>.*</nav>""" % label,
|
||||||
|
response.content.decode().replace('\n', '').lower()
|
||||||
|
)
|
||||||
|
|
||||||
|
found_url = None
|
||||||
|
if url != None:
|
||||||
|
url = url.lower()
|
||||||
|
found_url = re.search(
|
||||||
|
"""<nav.*>.*<a.*href=("|')%s("|')>.*</a>.*</nav>""" % url,
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
found_label != None and found_url != None,
|
||||||
|
msg='Expecting an menu item with either label \'%s\' or url \'%s\'' % (
|
||||||
|
label,
|
||||||
|
url
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def assertProfileMenu(self, response):
|
||||||
|
"""
|
||||||
|
Looks for a logout or login+signup link within the an header tag
|
||||||
|
"""
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""<header.*>.*(<a.*href=("|').*logout.*("|')|<a.*href=("|').*login.*("|').*<a.*href=("|').*signup.*("|')).*</header>""",
|
||||||
|
response.content.decode().replace('\n', '').lower()
|
||||||
|
),
|
||||||
|
msg='Expecting a profile menu containing either a logout link or a login and then a signup link'
|
||||||
|
)
|
||||||
|
|
||||||
class TaggableViewTestCaseMixin:
|
class TaggableViewTestCaseMixin:
|
||||||
|
|
||||||
def assertTaggableContext(self, context):
|
def assertTaggableContext(self, context):
|
||||||
@ -149,13 +242,13 @@ class TaggableViewTestCaseMixin:
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
'submit_url_name' in context,
|
'submit_url' in context,
|
||||||
msg='Expecting the context for taggable to contain \'submit_url_name\' attribute'
|
msg='Expecting the context for taggable to contain \'submit_url\' attribute'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
type(context['submit_url_name']) == str,
|
type(context['submit_url']) == str,
|
||||||
msg='Expecting submit_url_name to be of type string'
|
msg='Expecting submit_url to be of type string'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
#!/usr/bin/env python
|
23238#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from django.test import TestCase, RequestFactory, Client
|
from django.test import TestCase, RequestFactory, Client
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
|
from django.db import models
|
||||||
from django.contrib.auth.models import User, AnonymousUser
|
from django.contrib.auth.models import User, AnonymousUser
|
||||||
from django.contrib.messages.storage.fallback import FallbackStorage
|
from django.contrib.messages.storage.fallback import FallbackStorage
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
from lostplaces.models import Place
|
from lostplaces.models import Place
|
||||||
from lostplaces.views import IsAuthenticatedMixin
|
from lostplaces.views import (
|
||||||
|
IsAuthenticatedMixin,
|
||||||
|
PlaceAssetCreateView
|
||||||
|
)
|
||||||
from lostplaces.tests.views import ViewTestCase
|
from lostplaces.tests.views import ViewTestCase
|
||||||
|
from lostplaces.models import DummyAsset
|
||||||
|
|
||||||
class TestIsAuthenticated(ViewTestCase):
|
class TestIsAuthenticated(ViewTestCase):
|
||||||
view = IsAuthenticatedMixin
|
view = IsAuthenticatedMixin
|
||||||
@ -21,9 +27,6 @@ class TestIsAuthenticated(ViewTestCase):
|
|||||||
password='Develop123'
|
password='Develop123'
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.client = Client()
|
|
||||||
|
|
||||||
def test_logged_in(self):
|
def test_logged_in(self):
|
||||||
request = RequestFactory().get('/')
|
request = RequestFactory().get('/')
|
||||||
request.user = User.objects.get(id=1)
|
request.user = User.objects.get(id=1)
|
||||||
@ -33,16 +36,15 @@ class TestIsAuthenticated(ViewTestCase):
|
|||||||
self.assertHttpMethodNotAllowed(response)
|
self.assertHttpMethodNotAllowed(response)
|
||||||
|
|
||||||
def test_not_logged_in(self):
|
def test_not_logged_in(self):
|
||||||
request = RequestFactory().get('/someurl1234')
|
request = RequestFactory().get('/')
|
||||||
request.user = AnonymousUser()
|
request.user = AnonymousUser()
|
||||||
request.session = 'session'
|
request.session = 'session'
|
||||||
messages = FallbackStorage(request)
|
messages = FallbackStorage(request)
|
||||||
request._messages = messages
|
request._messages = messages
|
||||||
|
|
||||||
response = IsAuthenticatedMixin.as_view()(request)
|
response = IsAuthenticatedMixin.as_view()(request)
|
||||||
self.assertHttpRedirect(response, '?'.join([str(reverse_lazy('login')), 'next=/someurl1234']))
|
self.assertHttpRedirect(response, '?'.join([str(reverse_lazy('login')), 'next=/']))
|
||||||
|
|
||||||
response = self.client.get(response['Location'])
|
|
||||||
self.assertTrue(len(messages) > 0)
|
self.assertTrue(len(messages) > 0)
|
||||||
|
|
||||||
class TestIsPlaceSubmitterMixin(TestCase):
|
class TestIsPlaceSubmitterMixin(TestCase):
|
||||||
@ -87,3 +89,51 @@ class TestIsPlaceSubmitterMixin(TestCase):
|
|||||||
self.assertEqual(response.status_code, 403)
|
self.assertEqual(response.status_code, 403)
|
||||||
self.assertTrue(response.context['messages'])
|
self.assertTrue(response.context['messages'])
|
||||||
self.assertTrue(len(response.context['messages']) > 0)
|
self.assertTrue(len(response.context['messages']) > 0)
|
||||||
|
|
||||||
|
class TestPlaceAssetCreateView(ViewTestCase):
|
||||||
|
view = PlaceAssetCreateView
|
||||||
|
|
||||||
|
class DummyAssetCreateView(PlaceAssetCreateView):
|
||||||
|
model = DummyAsset
|
||||||
|
fields = ['name']
|
||||||
|
template_name = 'flat_form.html'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(cls):
|
||||||
|
user = User.objects.create_user(
|
||||||
|
username='testpeter',
|
||||||
|
password='Develop123'
|
||||||
|
)
|
||||||
|
|
||||||
|
place = Place.objects.create(
|
||||||
|
name='Im a place',
|
||||||
|
submitted_when=timezone.now(),
|
||||||
|
submitted_by=user.explorer,
|
||||||
|
location='Testtown',
|
||||||
|
latitude=50.5,
|
||||||
|
longitude=7.0,
|
||||||
|
description='This is just a test, do not worry'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_create_asset(self):
|
||||||
|
request = RequestFactory().post(
|
||||||
|
'/',
|
||||||
|
{
|
||||||
|
'name': 'im a place'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
request.user = User.objects.get(id=1)
|
||||||
|
|
||||||
|
response = TestPlaceAssetCreateView.DummyAssetCreateView.as_view()(request, place_id=1)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
DummyAsset.objects.all().count() >= 1,
|
||||||
|
msg='Expecting a dummy place asset to be created by the view'
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
DummyAsset.objects.get(id=1).name,
|
||||||
|
'im a place',
|
||||||
|
msg='Expecting the dummy place asset to have the correct data'
|
||||||
|
)
|
||||||
|
|
@ -1,10 +1,15 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
|
from os import path
|
||||||
|
|
||||||
from django.test import TestCase, Client
|
from django.test import TestCase, Client
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.conf import settings
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
from lostplaces.models import Place
|
from lostplaces.models import Place
|
||||||
@ -17,61 +22,61 @@ from lostplaces.forms import PlaceImageForm, PlaceForm
|
|||||||
from lostplaces.tests.views import (
|
from lostplaces.tests.views import (
|
||||||
ViewTestCase,
|
ViewTestCase,
|
||||||
TaggableViewTestCaseMixin,
|
TaggableViewTestCaseMixin,
|
||||||
MapableViewTestCaseMixin
|
MapableViewTestCaseMixin,
|
||||||
|
GlobalTemplateTestCaseMixin
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestPlaceCreateView(ViewTestCase):
|
class TestPlaceListView(GlobalTemplateTestCaseMixin, ViewTestCase):
|
||||||
view = PlaceCreateView
|
"""
|
||||||
|
Tests the view listing all placs
|
||||||
@classmethod
|
"""
|
||||||
def setUpTestData(cls):
|
|
||||||
user = User.objects.create_user(
|
|
||||||
username='testpeter',
|
|
||||||
password='Develop123'
|
|
||||||
)
|
|
||||||
|
|
||||||
place = Place.objects.create(
|
|
||||||
name='Im a place',
|
|
||||||
submitted_when=timezone.now(),
|
|
||||||
submitted_by=user.explorer,
|
|
||||||
location='Testtown',
|
|
||||||
latitude=50.5,
|
|
||||||
longitude=7.0,
|
|
||||||
description='This is just a test, do not worry'
|
|
||||||
)
|
|
||||||
place.tags.add('I a tag', 'testlocation')
|
|
||||||
place.save()
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.client = Client()
|
|
||||||
|
|
||||||
def test_has_forms(self):
|
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
|
||||||
response = self.client.get(reverse('place_create'))
|
|
||||||
|
|
||||||
self.assertHasForm(response, 'place_image_form', PlaceImageForm)
|
|
||||||
self.assertHasForm(response, 'place_form', PlaceForm)
|
|
||||||
|
|
||||||
|
|
||||||
class TestPlaceListView(ViewTestCase):
|
|
||||||
view = PlaceListView
|
view = PlaceListView
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
username='testpeter',
|
username='testpeter',
|
||||||
|
password='Develop123',
|
||||||
|
)
|
||||||
|
user.explorer.level = 3
|
||||||
|
user.explorer.save()
|
||||||
|
|
||||||
|
# default level should be 1, not setting required
|
||||||
|
other_user = User.objects.create_user(
|
||||||
|
username='blubberbernd',
|
||||||
password='Develop123'
|
password='Develop123'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
superuser = User.objects.create_user(
|
||||||
|
username='toor',
|
||||||
|
password='Develop123'
|
||||||
|
)
|
||||||
|
|
||||||
|
superuser.is_superuser = True
|
||||||
|
superuser.save()
|
||||||
|
|
||||||
|
Place.objects.create(
|
||||||
|
name='Im a own place',
|
||||||
|
submitted_when=timezone.now(),
|
||||||
|
submitted_by=other_user.explorer,
|
||||||
|
location='Test %d town' % 5,
|
||||||
|
latitude=50.5 + 5/10,
|
||||||
|
longitude=7.0 - 5/10,
|
||||||
|
description='This is just a test, do not worry %d' % 5,
|
||||||
|
level=3
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(12):
|
||||||
place = Place.objects.create(
|
place = Place.objects.create(
|
||||||
name='Im a place',
|
name='Im a place %d' % i,
|
||||||
submitted_when=timezone.now(),
|
submitted_when=timezone.now(),
|
||||||
submitted_by=user.explorer,
|
submitted_by=user.explorer,
|
||||||
location='Testtown',
|
location='Test %d town' % i,
|
||||||
latitude=50.5,
|
latitude=50.5 + i/10,
|
||||||
longitude=7.0,
|
longitude=7.0 - i/10,
|
||||||
description='This is just a test, do not worry'
|
description='This is just a test, do not worry %d' % i,
|
||||||
|
level=3
|
||||||
)
|
)
|
||||||
place.tags.add('I a tag', 'testlocation')
|
place.tags.add('I a tag', 'testlocation')
|
||||||
place.save()
|
place.save()
|
||||||
@ -84,7 +89,279 @@ class TestPlaceListView(ViewTestCase):
|
|||||||
response = self.client.get(reverse('place_list'))
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
self.assertContext(response, 'mapping_config')
|
self.assertContext(response, 'mapping_config')
|
||||||
|
self.assertGlobal(response)
|
||||||
|
|
||||||
|
def test_first_places(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
|
for i in range(1, 4):
|
||||||
|
place = Place.objects.get(id=i)
|
||||||
|
self.assertTrue(
|
||||||
|
place.name in response.content.decode(),
|
||||||
|
msg='Expecting the %dth place name to be on the first page of list' % i
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
place.description in response.content.decode(),
|
||||||
|
msg='Expecting the %dth place description to be on the first page of list' % i
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_pagination(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""<ul.*pagination.*>\s*(<li.*>.*</li>\s*){6,}</ul>""",
|
||||||
|
response.content.decode().replace('\n', '').lower()
|
||||||
|
),
|
||||||
|
msg='Expecting the place list to be paginated like [first] [previous] [item] at least 2 times [next] [last]'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_eligible_to_see_because_of_low_level(self):
|
||||||
|
self.client.login(username='blubberbernd', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
|
self.assertFalse(
|
||||||
|
'Im a place' in response.content.decode(),
|
||||||
|
msg='Expecting the user to not see any places'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_eligible_to_see_because_of_low_level_superuser(self):
|
||||||
|
self.client.login(username='toor', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'Im a place' in response.content.decode(),
|
||||||
|
msg='Expecting the superuser to see all places'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_eligible_to_see_because_of_low_level_own_place(self):
|
||||||
|
self.client.login(username='blubberbernd', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'Im a own place' in response.content.decode(),
|
||||||
|
msg='Expecting the user to see it\'s own places'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_eligible_to_see(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_list'))
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'Im a own place' in response.content.decode(),
|
||||||
|
msg='Expecting the user to see places where their level is high enough'
|
||||||
|
)
|
||||||
|
|
||||||
|
class TestPlaceCreateView(ViewTestCase):
|
||||||
|
view = PlaceCreateView
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(cls):
|
||||||
|
user = User.objects.create_user(
|
||||||
|
username='testpeter',
|
||||||
|
password='Develop123'
|
||||||
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.client = Client()
|
||||||
|
|
||||||
|
def test_has_forms(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_create'))
|
||||||
|
|
||||||
|
self.assertHasForm(response, 'place_image_form', PlaceImageForm)
|
||||||
|
self.assertHasForm(response, 'place_form', PlaceForm)
|
||||||
|
|
||||||
|
def test_positive_no_image(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('place_create'),
|
||||||
|
data={
|
||||||
|
'name': 'test place 486',
|
||||||
|
'location': 'test location',
|
||||||
|
'latitude': 45.804192,
|
||||||
|
'longitude': 1.860222,
|
||||||
|
'description': """
|
||||||
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
|
"""
|
||||||
|
},
|
||||||
|
follow=True
|
||||||
|
)
|
||||||
|
self.assertHttpOK(response)
|
||||||
|
place = Place.objects.get(name='test place 486')
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
place,
|
||||||
|
msg='Submitted place not found in database / model'
|
||||||
|
),
|
||||||
|
self.assertEqual(
|
||||||
|
reverse(
|
||||||
|
'place_detail', kwargs={'pk': place.id}
|
||||||
|
),
|
||||||
|
response.redirect_chain[-1][0]
|
||||||
|
)
|
||||||
|
self.assertMessage(
|
||||||
|
response,
|
||||||
|
_('Successfully created place'),
|
||||||
|
'success',
|
||||||
|
msg='Expecting a visible success message'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_positive_image(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
image = open(
|
||||||
|
path.join(
|
||||||
|
settings.BASE_DIR,
|
||||||
|
'testdata',
|
||||||
|
'test_image.jpg'
|
||||||
|
),
|
||||||
|
'rb'
|
||||||
|
)
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('place_create'),
|
||||||
|
data={
|
||||||
|
'name': 'test place 894',
|
||||||
|
'location': 'test location',
|
||||||
|
'latitude': 45.804192,
|
||||||
|
'longitude': 1.860222,
|
||||||
|
'description': """
|
||||||
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
|
""",
|
||||||
|
'filename': [image]
|
||||||
|
},
|
||||||
|
follow=True
|
||||||
|
)
|
||||||
|
self.assertHttpOK(response)
|
||||||
|
place = Place.objects.get(name='test place 894')
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
place,
|
||||||
|
msg='Submitted place not found in database / model'
|
||||||
|
),
|
||||||
|
self.assertEqual(
|
||||||
|
reverse(
|
||||||
|
'place_detail', kwargs={'pk': place.id}
|
||||||
|
),
|
||||||
|
response.redirect_chain[-1][0]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
len(place.placeimages.all()),
|
||||||
|
1,
|
||||||
|
msg='Expecting the place to have exactly 1 place image'
|
||||||
|
)
|
||||||
|
self.assertMessage(
|
||||||
|
response,
|
||||||
|
_('Successfully created place'),
|
||||||
|
'success',
|
||||||
|
msg='Expecting a visible success message'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_negative_no_name(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('place_create'),
|
||||||
|
{
|
||||||
|
'location': 'test location 456',
|
||||||
|
'latitude': 45.804192,
|
||||||
|
'longitude': 1.860222,
|
||||||
|
'description': """
|
||||||
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertHttpBadRequest(response)
|
||||||
|
self.assertEqual(
|
||||||
|
len(Place.objects.filter(location='test location 456')),
|
||||||
|
0,
|
||||||
|
msg='Expecting no place to be created'
|
||||||
|
)
|
||||||
|
self.assertMessage(
|
||||||
|
response,
|
||||||
|
_('Please fill in all required fields.'),
|
||||||
|
'error',
|
||||||
|
msg='Expecing a visible error message'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_negative_no_location(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('place_create'),
|
||||||
|
{
|
||||||
|
'name': 'test name 376',
|
||||||
|
'latitude': 45.804192,
|
||||||
|
'longitude': 1.860222,
|
||||||
|
'description': """
|
||||||
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertHttpBadRequest(response)
|
||||||
|
self.assertEqual(
|
||||||
|
len(Place.objects.filter(name='test name 376')),
|
||||||
|
0,
|
||||||
|
msg='Expecting no place to be created'
|
||||||
|
)
|
||||||
|
self.assertMessage(
|
||||||
|
response,
|
||||||
|
_('Please fill in all required fields.'),
|
||||||
|
'error',
|
||||||
|
msg='Expecing a visible error message'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_negative_no_latitude(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('place_create'),
|
||||||
|
{
|
||||||
|
'name': 'test name 417',
|
||||||
|
'location': 'location',
|
||||||
|
'longitude': 1.860222,
|
||||||
|
'description': """
|
||||||
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertHttpBadRequest(response)
|
||||||
|
self.assertEqual(
|
||||||
|
len(Place.objects.filter(name='test name 417')),
|
||||||
|
0,
|
||||||
|
msg='Expecting no place to be created'
|
||||||
|
)
|
||||||
|
self.assertMessage(
|
||||||
|
response,
|
||||||
|
_('Please fill in all required fields.'),
|
||||||
|
'error',
|
||||||
|
msg='Expecing a visible error message'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_negative_no_longitude(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.post(
|
||||||
|
reverse('place_create'),
|
||||||
|
{
|
||||||
|
'name': 'test name 417',
|
||||||
|
'location': 'location',
|
||||||
|
'latitude': 45.804192,
|
||||||
|
'description': """
|
||||||
|
Cupiditate harum reprehenderit ipsam iure consequuntur eaque eos reiciendis. Blanditiis vel minima minus repudiandae voluptate aut quia sed. Provident ex omnis illo molestiae. Ullam eos et est provident enim deserunt.
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.assertHttpBadRequest(response)
|
||||||
|
self.assertEqual(
|
||||||
|
len(Place.objects.filter(name='test name 417')),
|
||||||
|
0,
|
||||||
|
msg='Expecting no place to be created'
|
||||||
|
)
|
||||||
|
self.assertMessage(
|
||||||
|
response,
|
||||||
|
_('Please fill in all required fields.'),
|
||||||
|
'error',
|
||||||
|
msg='Expecing a visible error message'
|
||||||
|
)
|
||||||
|
|
||||||
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixin, ViewTestCase):
|
class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixin, ViewTestCase):
|
||||||
view = PlaceDetailView
|
view = PlaceDetailView
|
||||||
@ -95,6 +372,8 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
|||||||
username='testpeter',
|
username='testpeter',
|
||||||
password='Develop123'
|
password='Develop123'
|
||||||
)
|
)
|
||||||
|
user.explorer.level = 3
|
||||||
|
user.explorer.save()
|
||||||
|
|
||||||
place = Place.objects.create(
|
place = Place.objects.create(
|
||||||
name='Im a place',
|
name='Im a place',
|
||||||
@ -103,11 +382,85 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
|||||||
location='Testtown',
|
location='Testtown',
|
||||||
latitude=50.5,
|
latitude=50.5,
|
||||||
longitude=7.0,
|
longitude=7.0,
|
||||||
description='This is just a test, do not worry'
|
description='This is just a test, do not worry',
|
||||||
|
level=3
|
||||||
)
|
)
|
||||||
place.tags.add('I a tag', 'testlocation')
|
place.tags.add('I a tag', 'testlocation')
|
||||||
place.save()
|
place.save()
|
||||||
|
|
||||||
|
other_user = User.objects.create_user(
|
||||||
|
username='blubberbernd',
|
||||||
|
password='Develop123'
|
||||||
|
)
|
||||||
|
|
||||||
|
superuser = User.objects.create_user(
|
||||||
|
username='toor',
|
||||||
|
password='Develop123'
|
||||||
|
)
|
||||||
|
|
||||||
|
superuser.is_superuser = True
|
||||||
|
superuser.save()
|
||||||
|
|
||||||
|
Place.objects.create(
|
||||||
|
name='Im a own place',
|
||||||
|
submitted_when=timezone.now(),
|
||||||
|
submitted_by=other_user.explorer,
|
||||||
|
location='Test %d town' % 5,
|
||||||
|
latitude=50.5 + 5/10,
|
||||||
|
longitude=7.0 - 5/10,
|
||||||
|
description='This is just a test, do not worry %d' % 5,
|
||||||
|
level=3
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_eligible_to_see_because_of_low_level(self):
|
||||||
|
self.client.login(username='blubberbernd', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
|
||||||
|
self.assertFalse(
|
||||||
|
'Im a place' in response.content.decode(),
|
||||||
|
msg='Expecting the user to not see the places'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_eligible_to_see_because_of_low_level_superuser(self):
|
||||||
|
self.client.login(username='toor', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'Im a place' in response.content.decode(),
|
||||||
|
msg='Expecting the superuser to see all places'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_eligible_to_see_because_of_low_level_own_place(self):
|
||||||
|
self.client.login(username='blubberbernd', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 2}))
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'Im a own place' in response.content.decode(),
|
||||||
|
msg='Expecting the user to see it\'s own places'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_eligible_to_see(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 2}))
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
'Im a own place' in response.content.decode(),
|
||||||
|
msg='Expecting the user to see places where their level is high enough'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_not_authenticated(self):
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
self.assertHttpRedirect(response)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
'%s?next=%s' % (
|
||||||
|
reverse('login'),
|
||||||
|
reverse('place_detail', kwargs={'pk': 1})
|
||||||
|
),
|
||||||
|
response.url,
|
||||||
|
msg='Expecting unauthenticated user to be redirected to login page, using the \'next\' GET-Param to store the places details page'
|
||||||
|
)
|
||||||
|
|
||||||
def test_context(self):
|
def test_context(self):
|
||||||
self.client.login(username='testpeter', password='Develop123')
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
@ -127,3 +480,131 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.assertMapableContext(response.context['mapping_config'])
|
self.assertMapableContext(response.context['mapping_config'])
|
||||||
|
|
||||||
|
def test_place_data(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
place = Place.objects.get(id=1)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
place.name in response.content.decode(),
|
||||||
|
msg='Expecting the places name to be on the page'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
place.description in response.content.decode(),
|
||||||
|
msg='Expecting the places description to be on the page'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
str(place.latitude) in response.content.decode(),
|
||||||
|
msg='Expecting the places latitude to be on the page'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
str(place.longitude) in response.content.decode(),
|
||||||
|
msg='Expecting the places longitude to be on the page'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_favorite(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
|
||||||
|
user = User.objects.get(username='testpeter')
|
||||||
|
place = Place.objects.get(id=1)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
reverse('place_favorite', kwargs={'place_id': 1}) in response.content.decode(),
|
||||||
|
msg='Expecting the (right) create favorite url to be on the page '
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('place_favorite', kwargs={'place_id': 1}),
|
||||||
|
follow=True
|
||||||
|
)
|
||||||
|
self.assertHttpOK(response)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
reverse('place_unfavorite', kwargs={'place_id': 1}) in response.content.decode(),
|
||||||
|
msg='Expecting the (right) delete favorite url to be on the page '
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
place in user.explorer.favorite_places.all(),
|
||||||
|
msg='Expecting the place to be in the explorers favorites'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
user.explorer in place.explorer_favorites.all(),
|
||||||
|
msg='Expecting the explorere to be in the reverse list of favorites'
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('place_unfavorite', kwargs={'place_id': 1}),
|
||||||
|
follow=True
|
||||||
|
)
|
||||||
|
self.assertHttpOK(response)
|
||||||
|
self.assertTrue(
|
||||||
|
reverse('place_favorite', kwargs={'place_id': 1}) in response.content.decode(),
|
||||||
|
msg='Expecting the (right) create favorite url to be on the page after unfavorite'
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
place not in user.explorer.favorite_places.all(),
|
||||||
|
msg='Expecting the place to not be in the explorers favorites after unfavorite'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
user.explorer not in place.explorer_favorites.all(),
|
||||||
|
msg='Expecting the explorere to not be in the reverse list of favorites after unfavorite'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_visit(self):
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('place_detail', kwargs={'pk': 1}))
|
||||||
|
|
||||||
|
user = User.objects.get(username='testpeter')
|
||||||
|
place = Place.objects.get(id=1)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
reverse('place_visit_create', kwargs={'place_id': 1}) in response.content.decode(),
|
||||||
|
msg='Expecting the (right) create visit url to be on the page '
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('place_visit_create', kwargs={'place_id': 1}),
|
||||||
|
follow=True
|
||||||
|
)
|
||||||
|
self.assertHttpOK(response)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
reverse('place_visit_delete', kwargs={'place_id': 1}) in response.content.decode(),
|
||||||
|
msg='Expecting the (right) delete visist url to be on the page '
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
place in user.explorer.visited_places.all(),
|
||||||
|
msg='Expecting the place to be in the explorers visits'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
user.explorer in place.explorer_visits.all(),
|
||||||
|
msg='Expecting the explorer to be in the reverse list of visits'
|
||||||
|
)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse('place_visit_delete', kwargs={'place_id': 1}),
|
||||||
|
follow=True
|
||||||
|
)
|
||||||
|
self.assertHttpOK(response)
|
||||||
|
self.assertTrue(
|
||||||
|
reverse('place_visit_create', kwargs={'place_id': 1}) in response.content.decode(),
|
||||||
|
msg='Expecting the (right) create favorite url to be on the page after deleting visit'
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(
|
||||||
|
place not in user.explorer.visited_places.all(),
|
||||||
|
msg='Expecting the place to not be in the explorers visits after deleting visit'
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
user.explorer not in place.explorer_visits.all(),
|
||||||
|
msg='Expecting the explorer to not be in the reverse list of visits after deleting visit'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
156
django_lostplaces/lostplaces/tests/views/test_views.py
Normal file
156
django_lostplaces/lostplaces/tests/views/test_views.py
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
from django.test import TestCase, Client
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
|
from lostplaces.models import Place
|
||||||
|
|
||||||
|
from lostplaces.tests.views import (
|
||||||
|
ViewTestCase,
|
||||||
|
GlobalTemplateTestCaseMixin
|
||||||
|
)
|
||||||
|
|
||||||
|
class TestHomeView(GlobalTemplateTestCaseMixin, ViewTestCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpTestData(cls):
|
||||||
|
user = User.objects.create_user(
|
||||||
|
username='testpeter',
|
||||||
|
password='Develop123'
|
||||||
|
)
|
||||||
|
|
||||||
|
place = Place.objects.create(
|
||||||
|
name='Im a place',
|
||||||
|
submitted_when=timezone.now(),
|
||||||
|
submitted_by=user.explorer,
|
||||||
|
location='Testtown',
|
||||||
|
latitude=50.5,
|
||||||
|
longitude=7.0,
|
||||||
|
description='This is just a test, do not worry'
|
||||||
|
)
|
||||||
|
place.tags.add('I a tag', 'testlocation')
|
||||||
|
place.save()
|
||||||
|
|
||||||
|
# Creating a place with level one to test against
|
||||||
|
# unauth's users and users with level 1
|
||||||
|
Place.objects.create(
|
||||||
|
name='Im a place level 1',
|
||||||
|
submitted_when=timezone.now(),
|
||||||
|
submitted_by=user.explorer,
|
||||||
|
location='Testtown',
|
||||||
|
latitude=50.5,
|
||||||
|
longitude=7.0,
|
||||||
|
description='This is just a test, do not worry',
|
||||||
|
level=1
|
||||||
|
)
|
||||||
|
|
||||||
|
# Creating a place with level two to test against
|
||||||
|
# unauth's users and users above level 1
|
||||||
|
Place.objects.create(
|
||||||
|
name='Im a place level 2',
|
||||||
|
submitted_when=timezone.now(),
|
||||||
|
submitted_by=user.explorer,
|
||||||
|
location='Testtown',
|
||||||
|
latitude=50.5,
|
||||||
|
longitude=7.0,
|
||||||
|
description='This is just a test, do not worry',
|
||||||
|
level=2
|
||||||
|
)
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.client = Client()
|
||||||
|
|
||||||
|
def test_global(self):
|
||||||
|
response = self.client.get(reverse('lostplaces_home'))
|
||||||
|
self.assertGlobal(response)
|
||||||
|
|
||||||
|
def test_place_list_authenticated(self):
|
||||||
|
"""
|
||||||
|
Testing there is the place list containing the name,
|
||||||
|
location and description of the latest place for
|
||||||
|
authenticated users.
|
||||||
|
"""
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('lostplaces_home'))
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""Im a place.*Testtown.*This is just a test, do not worry""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg='Expecting the test place to show up on the homepage'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_place_list_unauthenticated(self):
|
||||||
|
"""
|
||||||
|
Testing there is a place list of the lates places
|
||||||
|
containing the place names only for unauthenticated users.
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse('lostplaces_home'))
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""Im a place""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg='Expecting the test place to show up on the homepage'
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""Testtown.*This is just a test, do not worry""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg='Expecting the test place to show up on the homepage'
|
||||||
|
)
|
||||||
|
|
||||||
|
print(response.content.decode().replace('\n', ''))
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""Im a place level 1""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg="Expecting the level 1 places to show up on the homepage publicly"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""Im a place level 2""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg="Expecting the level 2 places to *not* show up on the homepage publicly"
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_map_authenticated(self):
|
||||||
|
"""
|
||||||
|
Testing there is a map showing all the lates places
|
||||||
|
on a map for authenticated users.
|
||||||
|
"""
|
||||||
|
self.client.login(username='testpeter', password='Develop123')
|
||||||
|
response = self.client.get(reverse('lostplaces_home'))
|
||||||
|
self.assertNotEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""map.*7.0,.*50.5.*Im a place""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg='Expecting the test place to show up on the map'
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_map_unauthenticated(self):
|
||||||
|
"""
|
||||||
|
Testing there is no map for unauthenticated users.
|
||||||
|
"""
|
||||||
|
response = self.client.get(reverse('lostplaces_home'))
|
||||||
|
self.assertEqual(
|
||||||
|
None,
|
||||||
|
re.search(
|
||||||
|
"""7.0,.*50.5.*Im a place""",
|
||||||
|
response.content.decode().replace('\n', '')
|
||||||
|
),
|
||||||
|
msg='Expecting the test place to show up on the map'
|
||||||
|
)
|
@ -22,7 +22,8 @@ from lostplaces.views import (
|
|||||||
PhotoAlbumCreateView,
|
PhotoAlbumCreateView,
|
||||||
PhotoAlbumDeleteView,
|
PhotoAlbumDeleteView,
|
||||||
ExplorerProfileView,
|
ExplorerProfileView,
|
||||||
ExplorerProfileUpdateView
|
ExplorerProfileUpdateView,
|
||||||
|
PlaceVoteView
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -48,6 +49,8 @@ urlpatterns = [
|
|||||||
path('place_image/create/<int:place_id>/', PlaceImageCreateView.as_view(), name='place_image_create'),
|
path('place_image/create/<int:place_id>/', PlaceImageCreateView.as_view(), name='place_image_create'),
|
||||||
path('place_image/delete/<int:pk>/', PlaceImageDeleteView.as_view(), name='place_image_delete'),
|
path('place_image/delete/<int:pk>/', PlaceImageDeleteView.as_view(), name='place_image_delete'),
|
||||||
|
|
||||||
|
path('place/vote/<int:place_id>/<int:vote>', PlaceVoteView.as_view(), name='place_vote'),
|
||||||
|
|
||||||
path('photo_album/create/<int:place_id>/', PhotoAlbumCreateView.as_view(), name='photo_album_create'),
|
path('photo_album/create/<int:place_id>/', PhotoAlbumCreateView.as_view(), name='photo_album_create'),
|
||||||
path('photo_album/delete/<int:pk>/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete')
|
path('photo_album/delete/<int:pk>/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete')
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.generic.edit import CreateView
|
from django.views.generic.edit import CreateView
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
|
from django.views.generic import ListView
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
|
from django.contrib.auth.mixins import UserPassesTestMixin, LoginRequiredMixin
|
||||||
@ -26,6 +27,7 @@ class IsAuthenticatedMixin(LoginRequiredMixin, View):
|
|||||||
permission_denied_message = _('Please login to proceed')
|
permission_denied_message = _('Please login to proceed')
|
||||||
|
|
||||||
def handle_no_permission(self):
|
def handle_no_permission(self):
|
||||||
|
if not self.request.user.is_authenticated:
|
||||||
messages.error(self.request, self.permission_denied_message)
|
messages.error(self.request, self.permission_denied_message)
|
||||||
return super().handle_no_permission()
|
return super().handle_no_permission()
|
||||||
|
|
||||||
@ -60,7 +62,27 @@ class IsPlaceSubmitterMixin(UserPassesTestMixin, View):
|
|||||||
messages.error(self.request, self.place_submitter_error_message)
|
messages.error(self.request, self.place_submitter_error_message)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class IsEligibleToSeePlaceMixin(UserPassesTestMixin):
|
||||||
|
not_eligible_to_see_message = None
|
||||||
|
|
||||||
|
def get_place(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_func(self):
|
||||||
|
if not hasattr(self.request, 'user'):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if self.request.user.explorer.is_eligible_to_see(self.get_place()):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if self.not_eligible_to_see_message:
|
||||||
|
messages.error(self.request, self.not_eligible_to_see_message)
|
||||||
|
return False
|
||||||
|
|
||||||
class PlaceAssetCreateView(IsAuthenticatedMixin, SuccessMessageMixin, CreateView):
|
class PlaceAssetCreateView(IsAuthenticatedMixin, SuccessMessageMixin, CreateView):
|
||||||
|
"""
|
||||||
|
Abstract View for creating a place asset (i.e. PlaceImage)
|
||||||
|
"""
|
||||||
model = None
|
model = None
|
||||||
template_name = ''
|
template_name = ''
|
||||||
success_message = ''
|
success_message = ''
|
||||||
@ -110,3 +132,10 @@ class PlaceAssetDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, SingleOb
|
|||||||
self.get_object().delete()
|
self.get_object().delete()
|
||||||
messages.success(self.request, self.success_message)
|
messages.success(self.request, self.success_message)
|
||||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place_id}))
|
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place_id}))
|
||||||
|
|
||||||
|
|
||||||
|
class LevelCapPlaceListView(ListView):
|
||||||
|
model = Place
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return self.request.user.explorer.get_places_eligible_to_see()
|
@ -56,7 +56,6 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
|
|||||||
return render(request, 'explorer/profile_update.html', context)
|
return render(request, 'explorer/profile_update.html', context)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
print(request.POST)
|
|
||||||
explorer_user_change_form = ExplorerUserChangeForm(
|
explorer_user_change_form = ExplorerUserChangeForm(
|
||||||
request.POST,
|
request.POST,
|
||||||
instance=request.user
|
instance=request.user
|
||||||
@ -71,8 +70,6 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
|
|||||||
explorer_user_change_form.save()
|
explorer_user_change_form.save()
|
||||||
explorer_change_form.save()
|
explorer_change_form.save()
|
||||||
|
|
||||||
print(explorer_change_form.cleaned_data)
|
|
||||||
|
|
||||||
messages.success(
|
messages.success(
|
||||||
self.request,
|
self.request,
|
||||||
_('Successfully updated Explorer profile')
|
_('Successfully updated Explorer profile')
|
||||||
|
@ -18,6 +18,9 @@ class MultiplePlaceImageUploadMixin:
|
|||||||
submitted_by=submitted_by
|
submitted_by=submitted_by
|
||||||
)
|
)
|
||||||
place_image.save()
|
place_image.save()
|
||||||
|
if place.hero is None:
|
||||||
|
place.hero = place.placeimages.all()[0]
|
||||||
|
place.save()
|
||||||
|
|
||||||
class PlaceImageCreateView(MultiplePlaceImageUploadMixin, PlaceAssetCreateView):
|
class PlaceImageCreateView(MultiplePlaceImageUploadMixin, PlaceAssetCreateView):
|
||||||
model = PlaceImage
|
model = PlaceImage
|
||||||
|
@ -1,31 +1,42 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from django.db.models.functions import Lower
|
from django.db.models.functions import Lower
|
||||||
|
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
from django.views.generic import ListView
|
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from django.shortcuts import render, redirect, get_object_or_404
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy, reverse
|
||||||
|
|
||||||
from lostplaces.models import Place, PlaceImage
|
from lostplaces.models import (
|
||||||
from lostplaces.views.base_views import IsAuthenticatedMixin, IsPlaceSubmitterMixin
|
Place,
|
||||||
|
PlaceImage,
|
||||||
|
PlaceVoting,
|
||||||
|
PLACE_LEVELS
|
||||||
|
)
|
||||||
|
|
||||||
|
from lostplaces.views.base_views import (
|
||||||
|
IsAuthenticatedMixin,
|
||||||
|
IsPlaceSubmitterMixin,
|
||||||
|
LevelCapPlaceListView,
|
||||||
|
IsEligibleToSeePlaceMixin
|
||||||
|
)
|
||||||
from lostplaces.views.place_image_views import MultiplePlaceImageUploadMixin
|
from lostplaces.views.place_image_views import MultiplePlaceImageUploadMixin
|
||||||
from lostplaces.forms import PlaceForm, PlaceImageForm, TagSubmitForm
|
from lostplaces.forms import PlaceForm, PlaceImageForm, TagSubmitForm
|
||||||
from lostplaces.common import redirect_referer_or
|
from lostplaces.common import redirect_referer_or
|
||||||
|
|
||||||
from taggit.models import Tag
|
from taggit.models import Tag
|
||||||
|
|
||||||
class PlaceListView(IsAuthenticatedMixin, ListView):
|
class PlaceListView(IsAuthenticatedMixin, LevelCapPlaceListView):
|
||||||
paginate_by = 5
|
paginate_by = 5
|
||||||
model = Place
|
|
||||||
template_name = 'place/place_list.html'
|
template_name = 'place/place_list.html'
|
||||||
ordering = [Lower('name')]
|
ordering = [Lower('name')]
|
||||||
|
|
||||||
@ -37,9 +48,17 @@ class PlaceListView(IsAuthenticatedMixin, ListView):
|
|||||||
}
|
}
|
||||||
return context
|
return context
|
||||||
|
|
||||||
class PlaceDetailView(IsAuthenticatedMixin, View):
|
class PlaceDetailView(IsAuthenticatedMixin, IsEligibleToSeePlaceMixin, View):
|
||||||
|
not_eligible_to_see_message = _('You\'r not allowed to see this place')
|
||||||
|
|
||||||
|
def get_place(self):
|
||||||
|
return get_object_or_404(Place, pk=self.kwargs['pk'])
|
||||||
|
|
||||||
def get(self, request, pk):
|
def get(self, request, pk):
|
||||||
place = get_object_or_404(Place, pk=pk)
|
place = self.get_place()
|
||||||
|
place.calculate_place_level()
|
||||||
|
explorer = request.user.explorer
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'place': place,
|
'place': place,
|
||||||
'mapping_config': {
|
'mapping_config': {
|
||||||
@ -50,8 +69,12 @@ class PlaceDetailView(IsAuthenticatedMixin, View):
|
|||||||
'all_tags': Tag.objects.all(),
|
'all_tags': Tag.objects.all(),
|
||||||
'submit_form': TagSubmitForm(),
|
'submit_form': TagSubmitForm(),
|
||||||
'tagged_item': place,
|
'tagged_item': place,
|
||||||
'submit_url_name': 'place_tag_submit',
|
'submit_url': reverse('place_tag_submit', kwargs={'tagged_id': place.id}),
|
||||||
'delete_url_name': 'place_tag_delete'
|
'delete_url_name': 'place_tag_delete'
|
||||||
|
},
|
||||||
|
'placevoting': {
|
||||||
|
'users_vote': PlaceVoting.objects.filter(place=place, submitted_by=explorer).first(),
|
||||||
|
'all_choices': reversed(PLACE_LEVELS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return render(request, 'place/place_detail.html', context)
|
return render(request, 'place/place_detail.html', context)
|
||||||
@ -111,7 +134,8 @@ class PlaceCreateView(MultiplePlaceImageUploadMixin, IsAuthenticatedMixin, View)
|
|||||||
context={
|
context={
|
||||||
'place_form': place_form,
|
'place_form': place_form,
|
||||||
'place_image_form': PlaceImageForm()
|
'place_image_form': PlaceImageForm()
|
||||||
}
|
},
|
||||||
|
status=400
|
||||||
)
|
)
|
||||||
|
|
||||||
class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView):
|
class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView):
|
||||||
@ -128,10 +152,14 @@ class PlaceDeleteView(IsAuthenticatedMixin, IsPlaceSubmitterMixin, DeleteView):
|
|||||||
def get_place(self):
|
def get_place(self):
|
||||||
return self.get_object()
|
return self.get_object()
|
||||||
|
|
||||||
class PlaceFavoriteView(IsAuthenticatedMixin, View):
|
class PlaceFavoriteView(IsAuthenticatedMixin, IsEligibleToSeePlaceMixin, View):
|
||||||
|
not_eligible_to_see_message = _('You\'r not allowed to favorite this place')
|
||||||
|
|
||||||
|
def get_place(self):
|
||||||
|
return get_object_or_404(Place, pk=self.kwargs['place_id'])
|
||||||
|
|
||||||
def get(self, request, place_id):
|
def get(self, request, place_id):
|
||||||
place = get_object_or_404(Place, id=place_id)
|
place = self.get_place()
|
||||||
if request.user is not None:
|
if request.user is not None:
|
||||||
request.user.explorer.favorite_places.add(place)
|
request.user.explorer.favorite_places.add(place)
|
||||||
request.user.explorer.save()
|
request.user.explorer.save()
|
||||||
@ -148,10 +176,14 @@ class PlaceUnfavoriteView(IsAuthenticatedMixin, View):
|
|||||||
|
|
||||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
||||||
|
|
||||||
class PlaceVisitCreateView(IsAuthenticatedMixin, View):
|
class PlaceVisitCreateView(IsAuthenticatedMixin, IsEligibleToSeePlaceMixin, View):
|
||||||
|
not_eligible_to_see_message = _('You\'r not allowed to visit this place :P (Now please stop trying out URL\'s)')
|
||||||
|
|
||||||
|
def get_place(self):
|
||||||
|
return get_object_or_404(Place, pk=self.kwargs['place_id'])
|
||||||
|
|
||||||
def get(self, request, place_id):
|
def get(self, request, place_id):
|
||||||
place = get_object_or_404(Place, id=place_id)
|
place = self.get_place()
|
||||||
if request.user is not None:
|
if request.user is not None:
|
||||||
request.user.explorer.visited_places.add(place)
|
request.user.explorer.visited_places.add(place)
|
||||||
request.user.explorer.save()
|
request.user.explorer.save()
|
||||||
@ -167,3 +199,32 @@ class PlaceVisitDeleteView(IsAuthenticatedMixin, View):
|
|||||||
request.user.explorer.save()
|
request.user.explorer.save()
|
||||||
|
|
||||||
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
||||||
|
|
||||||
|
|
||||||
|
class PlaceVoteView(IsEligibleToSeePlaceMixin, View):
|
||||||
|
delta = timedelta(weeks=24)
|
||||||
|
|
||||||
|
def get(self, request, place_id, vote):
|
||||||
|
place = get_object_or_404(Place, id=place_id)
|
||||||
|
explorer = request.user.explorer
|
||||||
|
|
||||||
|
voting = PlaceVoting.objects.filter(
|
||||||
|
submitted_by=explorer,
|
||||||
|
place=place
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if voting is None:
|
||||||
|
voting = PlaceVoting.objects.create(
|
||||||
|
submitted_by=explorer,
|
||||||
|
place=place,
|
||||||
|
vote=vote,
|
||||||
|
expires_when=timezone.now()+self.delta
|
||||||
|
)
|
||||||
|
messages.success(self.request, _('Vote submitted'))
|
||||||
|
else:
|
||||||
|
voting.expires_when=timezone.now()+self.delta
|
||||||
|
voting.vote = vote
|
||||||
|
messages.success(self.request, _('Your vote has been update'))
|
||||||
|
|
||||||
|
voting.save()
|
||||||
|
return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk}))
|
@ -31,7 +31,7 @@ class SignUpView(SuccessMessageMixin, CreateView):
|
|||||||
|
|
||||||
class HomeView(IsAuthenticatedMixin, View):
|
class HomeView(IsAuthenticatedMixin, 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 = request.user.explorer.get_places_eligible_to_see()
|
||||||
context = {
|
context = {
|
||||||
'place_list': place_list,
|
'place_list': place_list,
|
||||||
'mapping_config': {
|
'mapping_config': {
|
||||||
@ -42,7 +42,7 @@ class HomeView(IsAuthenticatedMixin, View):
|
|||||||
return render(request, 'home.html', context)
|
return render(request, 'home.html', context)
|
||||||
|
|
||||||
def handle_no_permission(self):
|
def handle_no_permission(self):
|
||||||
place_list = Place.objects.all().order_by('-submitted_when')[:5]
|
place_list = Place.objects.filter(level=1)[:5]
|
||||||
context = {
|
context = {
|
||||||
'place_list': place_list
|
'place_list': place_list
|
||||||
}
|
}
|
||||||
|
5
django_lostplaces/lostplaces/widgets.py
Normal file
5
django_lostplaces/lostplaces/widgets.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django import forms
|
||||||
|
|
||||||
|
class SelectContent(forms.Select):
|
||||||
|
template_name = 'widgets/select_content.html'
|
||||||
|
|
@ -3,12 +3,14 @@
|
|||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
with open('../Readme.md') as f:
|
with open('Readme.md') as f:
|
||||||
readme = f.read()
|
readme = f.read()
|
||||||
|
|
||||||
|
# Keep PEP 440 for version identification in mind
|
||||||
|
# https://www.python.org/dev/peps/pep-0440/#post-releases
|
||||||
setup(
|
setup(
|
||||||
name='django-lostplaces',
|
name='django-lostplaces',
|
||||||
version='0.1.2 HotFix',
|
version='0.1.4.post1',
|
||||||
description='A django app to manage lost places',
|
description='A django app to manage lost places',
|
||||||
author='Reverend',
|
author='Reverend',
|
||||||
author_email='reverend@reverend2048.de',
|
author_email='reverend@reverend2048.de',
|
||||||
|
BIN
django_lostplaces/testdata/test_image.jpg
vendored
Normal file
BIN
django_lostplaces/testdata/test_image.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 89 KiB |
21
tasks.py
Normal file
21
tasks.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from invoke import task
|
||||||
|
|
||||||
|
@task
|
||||||
|
def quickstart(c):
|
||||||
|
commands = [
|
||||||
|
'pipenv run migrate',
|
||||||
|
'pipenv run createsuperuser',
|
||||||
|
'pipenv run server'
|
||||||
|
]
|
||||||
|
c.run(' && '.join(commands))
|
||||||
|
|
||||||
|
@task
|
||||||
|
def live(c):
|
||||||
|
commands = [
|
||||||
|
'pipenv check',
|
||||||
|
'pipenv run test',
|
||||||
|
'pipenv run migrate',
|
||||||
|
'pipenv run createsuperuser_prompt'
|
||||||
|
'pipenv run server'
|
||||||
|
]
|
||||||
|
c.run(' && '.join(commands))
|
Loading…
Reference in New Issue
Block a user