Compare commits

..

6 Commits

7 changed files with 38 additions and 36 deletions

View File

@ -21,9 +21,6 @@ class VoucherAdmin(admin.ModelAdmin):
valid.boolean = True valid.boolean = True
class PhotoAlbumsAdmin(admin.ModelAdmin):
list_display = ('label', 'place', 'url' )
class ExternalLinksAdmin(admin.ModelAdmin): class ExternalLinksAdmin(admin.ModelAdmin):
list_display = ('label', 'place', 'url', 'linktype' ) list_display = ('label', 'place', 'url', 'linktype' )
@ -37,5 +34,4 @@ admin.site.register(Explorer)
admin.site.register(Voucher, VoucherAdmin) 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(ExternalLink, ExternalLinksAdmin) admin.site.register(ExternalLink, ExternalLinksAdmin)

View File

@ -104,7 +104,7 @@ class PlaceAsset(Submittable):
""" """
class Meta: class Meta:
abstract = True abstract = True
place = models.ForeignKey( place = models.ForeignKey(
Place, Place,

View File

@ -104,16 +104,16 @@
</section> </section>
<section class=" LP-Section"> <section class=" LP-Section">
<h1 class="LP-Headline">{% translate 'Photo albums submitted by' %} {{explorer.user.username}}</h1> <h1 class="LP-Headline">{% translate 'External links 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 external_link in assets.externallinks.all %}
<li class="LP-LinkList__Item"> <li class="LP-LinkList__Item">
<a target="_blank" href="{{photo_album.url}}" class="LP-Link"> <a target="_blank" href="{{external_link.url}}" class="LP-Link">
<span class="LP-Text">{{photo_album.label}}</span> <span class="LP-Text">{{external_link.label}}</span>
</a> </a>
{% if user.explorer == photo_album.submitted_by%} {% if user.explorer == external_link.submitted_by%}
<a href="{% url 'photo_album_delete' pk=photo_album.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album"> <a href="{% url 'external_link_delete' pk=external_link.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album">
<div class="RV-Iconized__Container RV-Iconized__Container--small"> <div class="RV-Iconized__Container RV-Iconized__Container--small">
{% icon 'trash' className="RV-Iconized__Icon" %} {% icon 'trash' className="RV-Iconized__Icon" %}
</div> </div>

View File

@ -1,7 +1,7 @@
{% extends 'global.html'%} {% extends 'global.html'%}
{% load i18n %} {% load i18n %}
{% block title %}{% translate 'Submit a photo album' %}{% endblock %} {% block title %}{% translate 'Submit an external link' %}{% 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
@ -13,7 +13,7 @@
{% 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">{% translate 'Submit a photo album for' %} {{place.name}}</legend> <legend class="LP-Form__Legend">{% translate 'Submit an external link 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">
@ -27,6 +27,12 @@
</div> </div>
</div> </div>
<div class="LP-Form__Composition">
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=form.linktype %}
</div>
</div>
<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 %} {% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER %}
</div> </div>

View File

@ -62,16 +62,16 @@
</section> </section>
<section class=" LP-Section"> <section class=" LP-Section">
<h1 class="LP-Headline">{% translate 'Photo albums' %}</h1> <h2 class="LP-Headline">{% translate 'External links' %}</h2>
<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 external_link in place.externallinks.all %}
<li class="LP-LinkList__Item"> <li class="LP-LinkList__Item">
<a target="_blank" href="{{photo_album.url}}" class="LP-Link"> <a target="_blank" href="{{external_link.url}}" class="LP-Link">
<span class="LP-Text">{{photo_album.label}}</span> <span class="LP-Text">{{external_link.label}}</span>
</a> </a>
{% if user.explorer == photo_album.submitted_by or user.explorer == place.submitted_by %} {% if user.explorer == external_link.submitted_by or user.explorer == place.submitted_by %}
<a href="{% url 'photo_album_delete' pk=photo_album.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album"> <a href="{% url 'external_link_delete' pk=external_link.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete external link">
<div class="RV-Iconized__Container RV-Iconized__Container--small"> <div class="RV-Iconized__Container RV-Iconized__Container--small">
{% icon 'trash' className="RV-Iconized__Icon" %} {% icon 'trash' className="RV-Iconized__Icon" %}
</div> </div>
@ -80,7 +80,7 @@
</li> </li>
{% endfor %} {% endfor %}
<li class="LP-LinkList__Item"> <li class="LP-LinkList__Item">
<a href="{% url 'photo_album_create' place_id=place.id %}" class="LP-Link"> <a href="{% url 'external_link_create' place_id=place.id %}" class="LP-Link">
<div class="RV-Iconized__Container RV-Iconized__Container--small"> <div class="RV-Iconized__Container RV-Iconized__Container--small">
<svg class="RV-Iconized__Icon" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"> <svg class="RV-Iconized__Icon" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve">
<g> <g>
@ -88,7 +88,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">{% translate 'Add photo album' %}</span> <span class="RV-Iconized__Text">{% translate 'Add external link' %}</span>
</div> </div>
</a> </a>
</li> </li>

View File

@ -19,8 +19,8 @@ from lostplaces.views import (
PlaceVisitDeleteView, PlaceVisitDeleteView,
PlaceImageCreateView, PlaceImageCreateView,
PlaceImageDeleteView, PlaceImageDeleteView,
PhotoAlbumCreateView, ExternalLinkCreateView,
PhotoAlbumDeleteView, ExternalLinkDeleteView,
ExplorerProfileView, ExplorerProfileView,
ExplorerProfileUpdateView ExplorerProfileUpdateView
) )
@ -48,6 +48,6 @@ 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('photo_album/create/<int:place_id>/', PhotoAlbumCreateView.as_view(), name='photo_album_create'), path('external_link/create/<int:place_id>/', ExternalLinkCreateView.as_view(), name='external_link_create'),
path('photo_album/delete/<int:pk>/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete') path('external_link/delete/<int:pk>/', ExternalLinkDeleteView.as_view(), name='external_link_delete')
] ]

View File

@ -12,7 +12,7 @@ from django.http import HttpResponseForbidden
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from lostplaces.forms import SignupVoucherForm, TagSubmitForm from lostplaces.forms import SignupVoucherForm, TagSubmitForm
from lostplaces.models import Place, PhotoAlbum from lostplaces.models import Place, ExternalLink
from lostplaces.views.base_views import IsAuthenticatedMixin from lostplaces.views.base_views import IsAuthenticatedMixin
from lostplaces.common import redirect_referer_or from lostplaces.common import redirect_referer_or
@ -48,17 +48,17 @@ class HomeView(IsAuthenticatedMixin, View):
} }
return render(self.request, 'home_unauth.html', context) return render(self.request, 'home_unauth.html', context)
class PhotoAlbumCreateView(PlaceAssetCreateView): class ExternalLinkCreateView(PlaceAssetCreateView):
model = PhotoAlbum model = ExternalLink
fields = ['url', 'label'] fields = ['url', 'label', 'linktype']
template_name = 'photo_album/photo_album_create.html' template_name = 'external_link/external_link_create.html'
success_message = _('Photo album link submitted') success_message = _('External link submitted')
class PhotoAlbumDeleteView(PlaceAssetDeleteView): class ExternalLinkDeleteView(PlaceAssetDeleteView):
model = PhotoAlbum model = ExternalLink
pk_url_kwarg = 'pk' pk_url_kwarg = 'pk'
success_message = _('Photo album link deleted') success_message = _('External link deleted')
permission_denied_messsage = _('You are not allowed to edit this photo album link') permission_denied_messsage = _('You are not allowed to edit this external link')
class PlaceTagSubmitView(IsAuthenticatedMixin, View): class PlaceTagSubmitView(IsAuthenticatedMixin, View):
def post(self, request, tagged_id, *args, **kwargs): def post(self, request, tagged_id, *args, **kwargs):