commit ae826f38dbb58883a6afca263e4db31fee63563c Author: ottona Date: Wed Aug 10 00:38:10 2016 +0200 initial commit of current devel snapshot diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f78cf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc + diff --git a/blogapp/__init__.py b/blogapp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blogapp/admin.py b/blogapp/admin.py new file mode 100644 index 0000000..547ccfe --- /dev/null +++ b/blogapp/admin.py @@ -0,0 +1,23 @@ +from django import forms +from django.forms import ModelForm, Textarea +from blogapp.models import blogentry, blogcomment +from django.contrib import admin + +class blogentryAdminForm(forms.ModelForm): + class Meta: + model = blogentry + fields = '__all__' + widgets = { + 'intro': forms.Textarea(attrs={'cols': 80, 'rows': 20}), + 'body': forms.Textarea(attrs={'cols': 80, 'rows': 20}), + } + +class blogentryAdmin(admin.ModelAdmin): + form = blogentryAdminForm + list_display = ('header', ) + +class blogcommentAdmin(admin.ModelAdmin): + list_display = ('date', ) + +admin.site.register(blogentry, blogentryAdmin) +admin.site.register(blogcomment, blogcommentAdmin) diff --git a/blogapp/apps.py b/blogapp/apps.py new file mode 100644 index 0000000..03a0e83 --- /dev/null +++ b/blogapp/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BlogappConfig(AppConfig): + name = 'blogapp' diff --git a/blogapp/migrations/0001_initial.py b/blogapp/migrations/0001_initial.py new file mode 100644 index 0000000..eff7564 --- /dev/null +++ b/blogapp/migrations/0001_initial.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-01-09 13:09 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='blogcomment', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('guestname', models.CharField(max_length=20)), + ('body', models.CharField(max_length=300)), + ('date', models.DateTimeField(verbose_name='date')), + ], + ), + migrations.CreateModel( + name='blogentry', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date', models.DateTimeField(verbose_name='date')), + ('header', models.CharField(max_length=100)), + ('intro', models.CharField(max_length=1000)), + ('body', models.CharField(max_length=10000)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.AddField( + model_name='blogcomment', + name='blogentry', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='blogapp.blogentry'), + ), + migrations.AddField( + model_name='blogcomment', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/blogapp/migrations/__init__.py b/blogapp/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blogapp/models.py b/blogapp/models.py new file mode 100644 index 0000000..3bebfb7 --- /dev/null +++ b/blogapp/models.py @@ -0,0 +1,16 @@ +from django.db import models +from django.contrib.auth.models import User + +class blogentry(models.Model): + user = models.ForeignKey(User) + date = models.DateTimeField('date') + header = models.CharField(max_length=100) + intro = models.CharField(max_length=1000) + body = models.CharField(max_length=10000) + +class blogcomment(models.Model): + blogentry = models.ForeignKey(blogentry, on_delete=models.CASCADE) + user = models.ForeignKey(User) + guestname = models.CharField(max_length=20) + body = models.CharField(max_length=300) + date = models.DateTimeField('date') diff --git a/blogapp/static/blogapp/images/poly.png b/blogapp/static/blogapp/images/poly.png new file mode 100644 index 0000000..fa444ba Binary files /dev/null and b/blogapp/static/blogapp/images/poly.png differ diff --git a/blogapp/templates/blogapp/blogdetail.html b/blogapp/templates/blogapp/blogdetail.html new file mode 100644 index 0000000..508d239 --- /dev/null +++ b/blogapp/templates/blogapp/blogdetail.html @@ -0,0 +1,59 @@ +{% extends "base.html" %} + +{% block content %} +{% autoescape off %} + + + + + + +
+

{{blogentry.header}}

+ posted by {{blogentry.user.username}} on {{blogentry.date}} + +

+ {{blogentry.intro|linebreaks}}
+ {{blogentry.body|linebreaks}}

+ {% endautoescape %} + {% if not isfrontpage %} + Comments total: {{newsentry.newscomment_set.all.count}}
+ {% for newscomment in newsentry.newscomment_set.all %} + + + + + +

{{newscomment.user.username}}
{{ newscomment.commenttext|linebreaks|urlize }}
Datum: {{newscomment.date}}
+ {% endfor %} + + + + {% if commentform %} + + + + + {% else %} + + + + + {% endif %} + +
{{user.username}}
+
+ {% csrf_token %} + {{ commentform.newscomment }}
+ +
+
+ Please log in to post. +
+ {% endif %} +
+{% endblock %} + + diff --git a/blogapp/templates/blogapp/blogindex.html b/blogapp/templates/blogapp/blogindex.html new file mode 100644 index 0000000..ca5b528 --- /dev/null +++ b/blogapp/templates/blogapp/blogindex.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} + +{% block header %}Neuigkeiten - Übersicht {% endblock %} +{% block headline %}Neuigkeiten{% endblock %} + +{% block content %} +{% autoescape off %} +{% if blogentries %} +{% for blogentry in blogentries %} + +

+ {{ blogentry.header }}
+ posted on: {{blogentry.date}} by {{blogentry.user.username}} +

{{blogentry.intro|linebreaks}}

Read more...
+

+ +{% endfor %} +{% else %} +

No entries are available.

+{% endif %} +{% endautoescape %} +{% endblock %} + diff --git a/blogapp/tests.py b/blogapp/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/blogapp/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/blogapp/urls.py b/blogapp/urls.py new file mode 100644 index 0000000..451812d --- /dev/null +++ b/blogapp/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url(r'^$', views.listall, name='listall'), + url(r'^(?P\d+)/$', views.detail, name='detail'), + #url(r'^$', views.detail, name='detail'), +] diff --git a/blogapp/views.py b/blogapp/views.py new file mode 100644 index 0000000..c1f3b76 --- /dev/null +++ b/blogapp/views.py @@ -0,0 +1,73 @@ +from blogapp.models import blogentry, blogcomment +from django.shortcuts import render_to_response, get_object_or_404 +from django.template import RequestContext +from django import forms +import datetime + +class BlogCommentForm(forms.Form): + blogcomment = forms.CharField(widget=forms.Textarea(attrs={'rows':3, 'cols':30})) + + +def listall(request): + listall_entries = blogentry.objects.all().order_by('-date')[:10] + return render_to_response('blogapp/blogindex.html', {'blogentries': listall_entries}, context_instance=RequestContext(request)) + +def detail(request, blogentry_id): + blogdetail = get_object_or_404(blogentry, pk=blogentry_id) + + form = BlogCommentForm() + if request.user.is_authenticated(): + return render_to_response('blogapp/blogdetail.html', {'blogentry': blogdetail, 'commentform': form}, context_instance=RequestContext(request)) + else: + return render_to_response('blogapp/blogdetail.html', {'blogentry': blogdetail}, context_instance=RequestContext(request)) + +#def addarticle(request): +# if not request.user.is_staff: +# return listall(request) +# +# if request.method == 'POST': +# form = NewsForm(request.POST) +# if form.is_valid(): +# blog = blogentry() +# blog.user = request.user +# blog.newsheader = form.cleaned_data['header'] +# blog.newsbody = form.cleaned_data['body'] +# blog.date = datetime.datetime.now() +# blog.save() +# +# +# #return rather to the thread detail here +# listall_entries = newsentry.objects.all().order_by('date')[:10] +# return render_to_response('blogindex.html', {'listall_entries': listall_entries}, context_instance=RequestContext(request)) +# else: +# form = NewsForm() +# return render_to_response('blogindex.html', {'showaddnewsform' : form}, context_instance=RequestContext(request)) +# +#def editnews(request, newsentry_id): +# if not request.user.is_staff: +# return listall(request) +# +# newsdetail = get_object_or_404(newsentry, pk=newsentry_id) +# +# if request.method == 'POST': +# form = NewsForm(request.POST) +# if form.is_valid(): +# newsdetail.newsheader = form.cleaned_data['newsheader'] +# newsdetail.newsbody = form.cleaned_data['newsbody'] +# newsdetail.save() +# return detail(request, newsentry_id) +# +# +# data = {'newsheader': newsdetail.newsheader, 'newsbody': newsdetail.newsbody} +# form = NewsForm(data) +# return render_to_response('newsedit.html', {'editform' : form}, context_instance=RequestContext(request)) +# +#d#ef showfrontpage(request): +#0 newsdetail = get_object_or_404(newsentry, pk=1) +# return render_to_response('newsapp/newsdetail.html', {'newsentry': newsdetail, 'isfrontpage': True}, context_instance=RequestContext(request)) +# +# +#d#ef getincludes(request): +# eventlist = evententry.objects.all().order_by('-date')[:10] +# appointmentlist = event.objects.all().filter(eventend__gte = datetime.datetime.now()).order_by('eventstart')[:5] +# return {'eventlist' : eventlist, 'appointmentlist' : appointmentlist} diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..1e683c2 --- /dev/null +++ b/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "polysite.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/polysite/__init__.py b/polysite/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/polysite/settings.py b/polysite/settings.py new file mode 100644 index 0000000..05e7afb --- /dev/null +++ b/polysite/settings.py @@ -0,0 +1,133 @@ +""" +Django settings for polysite project. + +Generated by 'django-admin startproject' using Django 1.9.1. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.9/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'c=62ybp2ppak&@1r+x(cc)u+iw9%ljsq8-w10h9a14##)51yh3' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'blogapp.apps.BlogappConfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'polysite.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + '/home/ottona/Projekte/polysite/templates', + '/home/ottona/Projekte/polysite/blogapp/templates/blogapp', + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'polysite.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.9/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'djangotest', + 'USER': 'pguser', + 'PASSWORD': '', + 'HOST': '127.0.0.1', + 'PORT': '5432', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/1.9/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ + +STATIC_URL = '/static/' +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "static"), + '/home/ottona/Projekte/polysite/static', +] diff --git a/polysite/urls.py b/polysite/urls.py new file mode 100644 index 0000000..fdbb9c8 --- /dev/null +++ b/polysite/urls.py @@ -0,0 +1,22 @@ +"""polysite URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.9/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin + +urlpatterns = [ + url(r'^blog/', include('blogapp.urls')), + url(r'^admin/', admin.site.urls), +] diff --git a/polysite/wsgi.py b/polysite/wsgi.py new file mode 100644 index 0000000..ecdd5a0 --- /dev/null +++ b/polysite/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for polysite project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "polysite.settings") + +application = get_wsgi_application() diff --git a/static/poly.png b/static/poly.png new file mode 100644 index 0000000..fa444ba Binary files /dev/null and b/static/poly.png differ diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..7a3694c --- /dev/null +++ b/templates/base.html @@ -0,0 +1,137 @@ + + + + {% load staticfiles %} + + {% block head %}{% endblock %} + + polylux + + + +
+ +
+
+
  • Home
  • Blog
+
+ + + + + + + + + + +
+ + + + + +{% for page in pages %} + +{% endfor %} + + + +
Home
+
Blog
+
Static Page
+
Forum
+
+
+ + + + + + +
+
+ + + + + + + + + + + +
{% block headline %} {% endblock %}
+
+ User stuff + +
+ {% if errormsg %} + + + + + + +
Error:
+
    +
  • {{ errormsg }}
    +
  • +
+
+ {% endif %} +{% block content %} {% endblock %}
+

+ {% block sidebar %} + {% if eventlist %} + Aktivitäten: + + {% for evententry in eventlist %} + + {% endfor %} +
+ {% ifchanged evententry.date.date %}
{{evententry.date|date:"d. M."}}:
{% endifchanged %}{{evententry.user.username}} {{ evententry.eventmessage }}
+
+

+ {% endif %} + + + {% if appointmentlist %} + Termine: + + {% for obj in appointmentlist %} + + {% endfor %} +
+ {{obj.eventname}}
+ {% ifequal obj.eventstart.date obj.eventend.date%} + {{obj.eventstart|date:"d. M. H"}}Uhr + {% else %} + {{obj.eventstart|date:"d. M."}}-{{obj.eventend|date:"d. M."}} + {% endifequal %} + ({{ obj.getUsersAttending.count }} Gäste) +
+
+ {% endif %} + {% endblock %} +
+ + ofl Webpage
+ (c) polylux
+ Site realized utilizing Django, a great and powerful python-based web development framework.
+ Thanks to davidst for hosting this site. +
+
+
+
+ +
+ +
+ + + diff --git a/templates/staticpages/viewpage.html b/templates/staticpages/viewpage.html new file mode 100644 index 0000000..0bd5ed5 --- /dev/null +++ b/templates/staticpages/viewpage.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block content %} +{% autoescape off %} + + + + + + +
+

{{ pagecontent.caption }}

+ last edited by {{ pagecontent.user.username }} on {{ pagecontent.date }} + +

+ {{pagecontent.content|linebreaks}}

+
+{% endautoescape %} +{% endblock %} + + diff --git a/templates/usermanager/userdetail.html b/templates/usermanager/userdetail.html new file mode 100644 index 0000000..f30d0b0 --- /dev/null +++ b/templates/usermanager/userdetail.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} + +{% block content %} + + + + + + +
Test + {% if displayuser %} + Name: {{displayuser.username}}
+ Wohnt in: {{displayuser.get_profile.userlocation}}
+ AS-Ausrüstung: {{displayuser.get_profile.userequipment}}
+ Forumbeiträge gesamt: {{displayuser.get_profile.forumtotal}}
+ Kommentare gesamt: {{displayuser.get_profile.commenttotal}}
+ {% endif %} + Hier entsteht in Kürze die Infoseite für Benutzerkonten. ;) +
+{% endblock %} + diff --git a/templates/usermanager/useredit.html b/templates/usermanager/useredit.html new file mode 100644 index 0000000..06ef2cf --- /dev/null +++ b/templates/usermanager/useredit.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block content %} + + + + + + +
+

Benutzerdetails editieren:

+
+ {% csrf_token %} + Benutzername:
+ {{ user.username }} (not editable)

+ First Name:
+ {{ editform.firstname }} (optional)

+ Last Name:
+ {{ editform.lastname }} (optional)

+ EMail-Address:
+ {{ editform.email }} (optional)

+ Password:
+ {{ editform.password }}
+ Hint: Leave this field empty if you don't want to change your password.
+ +
+ + +
+{% endblock %} + diff --git a/templates/usermanager/userinfoedit.html b/templates/usermanager/userinfoedit.html new file mode 100644 index 0000000..5e8ccf9 --- /dev/null +++ b/templates/usermanager/userinfoedit.html @@ -0,0 +1,53 @@ +{% extends "base.html" %} + +{% block content %} + + + + + + +
+ {% if editform %} +

Benutzerinfo editieren:

+ Note: All fields are optional.

+
+ Bild:
+
+ Upload new image...

+ Description:
+ Some info / bio about you.
+ {{ editform.userdescription }}

+ Location:
+ {{ editform.userlocation }}

+ Forum Short Description:
+ Small desc / title for the forum. 50 chars max.
+ {{ editform.userforuminfo }}

+ Skype:
+ Your Skype username
+ {{ editform.userskype }}

+ ICQ:
+ Your ICQ user id
+ {{ editform.usericq }}

+ Jabber / XMPP:
+ Your XMPP identifier:
+ {{ editform.userjabber }}

+ + +
+ {% endif %} + {% if imageform %} +

Current Image:

+

+

Change Image:

+ Note: The image is scaled to 64 x 64 pixels.
+ Hence use a mostly quadratic image.

+
+ Image:
+ {{ imageform.userimage }}
+ +
+ {% endif %} +
+{% endblock %} + diff --git a/templates/usermanager/userlogin.html b/templates/usermanager/userlogin.html new file mode 100644 index 0000000..d227ddf --- /dev/null +++ b/templates/usermanager/userlogin.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} + +{% block content %} + + + + + + + +
+

Login:

+ (Create a new user instead?)

+
+ {% csrf_token %} + Username:
+ {{ editform.username }} (required)

+ Password:
+ {{ editform.password }} (required)

+ +
+ + +
+{% endblock %} + diff --git a/templates/usermanager/usernew.html b/templates/usermanager/usernew.html new file mode 100644 index 0000000..d8c8df8 --- /dev/null +++ b/templates/usermanager/usernew.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} + +{% block content %} + + + + + + +
+

Create a new user:

+
+ {% csrf_token %} + Username:
+ Your login, not changeable. Stay alphanumeric.
+ {{ editform.username }} (required)

+ Email Address:
+ {{ editform.email }} (optional)

+ Low Security Captcha:
+ Enter the word 'linux' inverted (back front)
+ {{ editform.botquestion }} (required)

+ Password:
+ {{ editform.password }} (required)

+ +
+
+{% endblock %} +