Skip to content
Snippets Groups Projects
Commit 2638877d authored by Christian Dresen's avatar Christian Dresen
Browse files

Warpmain

Added Main-App with NEWS Function
parent ab94383a
No related branches found
No related tags found
No related merge requests found
Showing
with 264 additions and 11 deletions
from django.conf.urls import url
from warpauth.views import main, login, reset_password, profile
from warpauth.views.admin import dashboard
#
# Definition of all available URLS for accessing Functions integrated in WarpAuth
#
urlpatterns = [
# Authentication Pages
......@@ -12,7 +17,4 @@ urlpatterns = [
url(r'^profile/$', profile.index, name='index'),
url(r'^profile/change_password/$', profile.change_password, name='change_password'),
# Main Page
url(r'^$', main.index, name='index'),
]
from django.contrib import admin
# Register your models here.
from warpmain.models import News
@admin.register(News)
class NewsAdmin(admin.ModelAdmin):
pass
from django.apps import AppConfig
class WarpmainConfig(AppConfig):
name = 'warpmain'
from __future__ import unicode_literals
from django.db import models
from django.forms import ModelForm
class News(models.Model):
user = models.CharField(max_length=100, null=True)
title = models.CharField(max_length=100)
message = models.TextField()
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
class NewsForm(ModelForm):
class Meta:
model = News
fields = ['title', 'message']
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<h2>{% trans "About" %}</h2>
<p class="lead">Welcome to Warpzone Internal</p>
<p>
<img class="img-responsive" style="margin-left: 100px; display: inline; float:right" src="/media/warpzone_logo_orig.png">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</p>
<a href="http://www.warpzone.ms/" target="_blank" class="btn btn-default btn-default">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span> {% trans "Visit us!" %}
</a>
<h3>License</h3>
<button data-toggle="modal" data-target="#Modal" class="btn btn-default">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> Licenses
</button>
<h3>Support</h3>
<p>{% trans "If you have any questions about this software, feel free to contact me or one of the coders club:"%}</p>
<a href="mailto:dresen@itsecteam.ms" style="text-decoration: none;">
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> dresen@itsecteam.ms
</button>
</a>
<br>
<br>
<br>
<br>
<img height="40px" src="/media/django_logo.gif">
<div class="modal fade" id="Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document" ">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Open Source Licenses</h4>
</div>
<div class="modal-body">
<h3>django</h3><br>
<pre>{% include "licenses/django.txt" %}</pre>
</div>
<div class="modal-body">
<h3>chart.js</h3><br>
<pre>{% include "licenses/chart_js.txt" %}</pre>
</div>
</div>
</div>
</div>
{% endblock %}
{% extends "base.html" %}
{% block content %}
HAllo
{% endblock %}
\ No newline at end of file
{% extends "base.html" %}
{% load humanize %}
{% load i18n %}
{% load bootstrap %}
{% block content %}
<div class="panel panel-default">
<div class="panel-body">
<form class="form-horizontal" method="POST" role="form">
{{ create_news_form | bootstrap_horizontal }}
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
{% csrf_token %}
<button style="float: left" type="submit" formmethod="post" class="btn btn-primary">{% trans "Create News" %}</button>
</div>
</div>
</form>
</div>
</div>
{% for news in news_list %}
<div class="panel panel-primary">
<div class="panel-heading">
<span class="lead">{{ news.title }}</span>
</div>
<div class="panel-body">
{{ news.message }}
</div>
<div class="panel-footer">
{% trans "Created by" %} {{ news.user }} {{ news.created | naturaltime }}
</div>
</div>
{% endfor %}
{% endblock %}
{% extends "base.html" %}
{% load humanize %}
{% load i18n %}
{% block content %}
<h2>{% trans "News" %}</h2>
{% for news in news_list %}
<div class="panel panel-primary">
<div class="panel-heading">
<span class="lead">{{ news.title }}</span>
</div>
<div class="panel-body">
{{ news.message }}
</div>
<div class="panel-footer">
{% trans "Created by" %} {{ news.user }} {{ news.created | naturaltime }}
</div>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from warpmain.views import main
from warpmain.views.admin import dashboard, news
# ToDo: Use name tag of URL for Page Title
urlpatterns = [
url(r'^$', main.index, name='News'),
url(r'^about/$', main.about, name='About'),
url(r'^administration/$', dashboard.index, name='admin_dashboard'),
url(r'^administration/news/$', news.news, name='admin_news'),
]
__author__ = 'chris'
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from warpauth.util import *
@login_required(login_url='/login/', redirect_field_name=None)
def index(request):
return HttpResponse(render(request, 'warpmain/admin/dashboard.html', pages))
from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from warpauth.util import *
from warpmain.models import News, NewsForm
# ToDo: Not ready yet
@login_required(login_url='/login/', redirect_field_name=None)
def news(request, news_id=0):
if request.method == "POST":
news_form = NewsForm(request.POST)
if news_form.is_valid():
news = news_form.save()
news.user = request.user.ldap_username
news.save()
return redirect("/administration/news/")
else:
pages['create_news_form'] = news_form
else:
pages['news_list'] = News.objects.order_by("created")
pages['create_news_form'] = NewsForm()
if news_id != 0:
pages['create_news_form'] = NewsForm(News.objects.get(id=news_id))
return HttpResponse(render(request, 'warpmain/admin/news.html', pages))
@login_required(login_url='/login/', redirect_field_name=None)
def news_delete(request, news_id=0):
pass
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from warpauth.util import *
from warpmain.models import News
@login_required(login_url='/login/', redirect_field_name=None)
def index(request):
pages['news_list'] = News.objects.order_by("created")
return HttpResponse(render(request, 'warpmain/main.html', pages))
def about(request):
return HttpResponse(render(request, 'warpmain/about.html', pages))
......@@ -10,6 +10,14 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
#
# MAIN TO DO LIST
#
# ToDo: Add Content Security Policy
# ToDo: Fix UTF-8 for all Strings
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import ldap
......@@ -43,7 +51,9 @@ INSTALLED_APPS = (
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'bootstrapform',
'warpmain',
'warpauth',
'warpfood',
)
......@@ -79,6 +89,9 @@ TEMPLATES = [
WSGI_APPLICATION = 'warpzone.wsgi.application'
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
......@@ -90,7 +103,8 @@ DATABASES = {
},
'ldap': {
'ENGINE': 'ldapdb.backends.ldap',
'NAME': 'ldap://s1.dyhost.de/',
# 'NAME': 'ldap://s1.dyhost.de/',
'NAME': 'ldap://localhost/',
'USER': 'cn=admin,dc=warpzone,dc=ms',
'PASSWORD': '12345',
}
......@@ -121,21 +135,28 @@ AUTHENTICATION_BACKENDS = (
)
AUTH_LDAP_SERVER_URI = "ldap://s1.dyhost.de"
#
# AUTH LDAP SETTINGS
#
# AUTH_LDAP_SERVER_URI = "ldap://s1.dyhost.de"
AUTH_LDAP_SERVER_URI = "ldap://localhost"
AUTH_LDAP_BIND_DN = "cn=admin,dc=warpzone,dc=ms"
AUTH_LDAP_BIND_PASSWORD = "12345"
LDAP_USER_SEARCH_PATH = "ou=User,dc=warpzone,dc=ms"
AUTH_LDAP_USER_SEARCH = LDAPSearch(LDAP_USER_SEARCH_PATH,
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
AUTH_LDAP_USER_SEARCH_PATH = "ou=User,dc=warpzone,dc=ms"
AUTH_LDAP_USER_SEARCH_FILTER = "(uid=%(user)s)"
AUTH_LDAP_USER_SEARCH = LDAPSearch(AUTH_LDAP_USER_SEARCH_PATH,
ldap.SCOPE_SUBTREE, AUTH_LDAP_USER_SEARCH_FILTER)
AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "description"}
AUTH_LDAP_PROFILE_ATTR_MAP = {"home_directory": "homeDirectory"}
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=Groups,dc=warpzone,dc=ms",
AUTH_LDAP_GROUP_SEARCH_PATH = "ou=Groups,dc=warpzone,dc=ms"
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(AUTH_LDAP_GROUP_SEARCH_PATH,
ldap.SCOPE_SUBTREE, "(objectClass=posixGroup)"
)
......@@ -157,3 +178,9 @@ logger = logging.getLogger('django_auth_ldap')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
#
# MISC
#
# Lifetime of Password Reset Token in Minutes
PW_RESET_TOKEN_LIFETIME = 5
import django
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, }),
url(r'^', include('warpmain.urls')),
url(r'^', include('warpauth.urls')),
url(r'^', include('warpfood.urls')),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment