diff --git a/Dockerfile b/Dockerfile
index 4a70a5e..b80d6d8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,6 +2,8 @@ FROM python:3.5
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
+RUN apt-get -y update
+RUN apt-get -y install libsasl2-dev libldap2-dev libssl-dev
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/
diff --git a/requirements.txt b/requirements.txt
index c2d3dfb..09dc122 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,7 @@
Django==1.10.1
git+https://github.com/djangonauts/django-hstore@61427e474cb2f4be8fdfce225d78a5330bc77eb0#egg=django-hstore
django-appconf==1.0.2
+django-auth-ldap==1.2.9
Django-Select2==5.8.10
Pillow==3.3.1
psycopg2==2.6.2
diff --git a/spejstore/settings.py b/spejstore/settings.py
index f14b1e5..c89e2e9 100644
--- a/spejstore/settings.py
+++ b/spejstore/settings.py
@@ -109,6 +109,41 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
+import ldap
+from django_auth_ldap.config import LDAPSearch, GroupOfUniqueNamesType
+
+AUTHENTICATION_BACKENDS = (
+ 'django_auth_ldap.backend.LDAPBackend',
+ 'django.contrib.auth.backends.ModelBackend',
+)
+
+AUTH_LDAP_SERVER_URI = "ldaps://ldap.hackerspace.pl"
+AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=People,dc=hackerspace,dc=pl"
+AUTH_LDAP_BIND_AS_AUTHENTICATING_USER = True
+
+AUTH_LDAP_USER_FLAGS_BY_GROUP = {
+ "is_active": "cn=staff,ou=Group,dc=hackerspace,dc=pl",
+ "is_superuser": "cn=staff,ou=Group,dc=hackerspace,dc=pl",
+ "is_staff": "cn=staff,ou=Group,dc=hackerspace,dc=pl",
+ }
+
+# Populate the Django user from the LDAP directory.
+AUTH_LDAP_USER_ATTR_MAP = {
+ "first_name": "givenName",
+ "last_name": "sn",
+ "email": "mail"
+}
+
+AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=Group,dc=hackerspace,dc=pl",
+ ldap.SCOPE_SUBTREE, "(objectClass=groupOfUniqueNames)"
+)
+AUTH_LDAP_GROUP_TYPE = GroupOfUniqueNamesType(name_attr="cn")
+
+import logging
+
+logger = logging.getLogger('django_auth_ldap')
+logger.addHandler(logging.StreamHandler())
+logger.setLevel(logging.DEBUG)
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
@@ -132,3 +167,6 @@ STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
+
+MEDIA_URL = '/media/'
+MEDIA_ROOT = os.path.join(BASE_DIR, "media")
diff --git a/spejstore/urls.py b/spejstore/urls.py
index 8d51380..5645533 100644
--- a/spejstore/urls.py
+++ b/spejstore/urls.py
@@ -14,4 +14,6 @@ urlpatterns = [
url(r'^select2/', include('django_select2.urls')),
url(r'^', include('storage.urls')),
-] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
+] \
+ + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \
+ + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/storage/admin.py b/storage/admin.py
index 99e99df..bcb4f21 100644
--- a/storage/admin.py
+++ b/storage/admin.py
@@ -20,10 +20,11 @@ class ItemImageInline(admin.TabularInline):
extra = 1
class ItemAdmin(admin.ModelAdmin):
- list_display = ('_name', 'uuid', 'props', 'path')
+ list_display = ('_name',)
list_filter = ('categories',)
form = ItemForm
inlines = [ItemImageInline]
+ save_on_top = True
def _name(self, obj):
return '-' * obj.get_level() + '> ' + obj.name
diff --git a/storage/templates/admin/storage/item/change_form.html b/storage/templates/admin/storage/item/change_form.html
index 6e57c57..aa7dff0 100644
--- a/storage/templates/admin/storage/item/change_form.html
+++ b/storage/templates/admin/storage/item/change_form.html
@@ -1,5 +1,11 @@
{% extends "admin/change_form.html" %}
+{% block submit_buttons_top %}
+ {# We want add another to be default submit action #}
+
+ {{ block.super }}
+{% endblock %}
+
{% block submit_buttons_bottom %}
{# We want add another to be default submit action #}
diff --git a/storage/templates/item.html b/storage/templates/item.html
index ea38fa6..bbc82c8 100644
--- a/storage/templates/item.html
+++ b/storage/templates/item.html
@@ -8,10 +8,13 @@
{% endfor %}
{{ item.name }}
- {{ item.name }} {{ item.pk }}
+
+
+ {{ item.name }} {{ item.pk }}
+
- {% if item.props %}
+
Properties
@@ -20,19 +23,37 @@
{% for k, v in item.props.items %}
- {{ k }} | {{ v }} |
+ {{ k }} | {{ v|urlize }} |
+ {% empty %}
+ No properties |
{% endfor %}
+
+ {% if images %}
+
Photos
+
+ {% for image in images %}
+
+ {% endfor %}
+
{% endif %}
-
- {% if children %}
- Children
-
- {% endif %}
+
+ {{ item.description|urlize }}
+
+
Children
+
+ {% for child in children %}
+ {{ child.name }} |
+ {% empty %}
+ No children |
+ {% endfor %}
+
+
+
{% endblock %}
diff --git a/storage/views.py b/storage/views.py
index d775a1c..587b14d 100644
--- a/storage/views.py
+++ b/storage/views.py
@@ -60,6 +60,7 @@ def item_display(request, pk):
return render(request, 'item.html', {
'item': item,
+ 'images': item.images.all(),
'ancestors': item.get_ancestors(),
'children': item.get_children(),
})