implemented django wiki, created requests page, and added to nav

This commit is contained in:
Oliver Marks 2017-09-05 20:07:48 +01:00
parent 10024c6646
commit fbaa7fb50d
18 changed files with 403 additions and 49 deletions

2
.gitignore vendored
View File

@ -7,4 +7,4 @@ src
staticfiles/*
cache/
celerybeat-schedule
celerybeat.pid

View File

@ -81,9 +81,11 @@ THIRD_PARTY_APPS = (
'stdimage',
'rest_framework',
'draceditor',
'haystack',
'djconfig',
'corsheaders',
'spirit.core',
'spirit.admin',
'spirit.search',
@ -111,6 +113,16 @@ THIRD_PARTY_APPS = (
'spirit.comment.history',
'spirit.comment.like',
'spirit.comment.poll',
'django_nyt',
'mptt',
'sekizai',
'sorl.thumbnail',
'wiki',
'wiki.plugins.attachments',
'wiki.plugins.notifications',
'wiki.plugins.images',
'wiki.plugins.macros',
)
# Apps specific for this project go here.
@ -124,6 +136,7 @@ LOCAL_APPS = (
'mhackspace.contact',
'mhackspace.members',
'mhackspace.blog',
'mhackspace.core',
'mhackspace.requests',
)
@ -136,6 +149,7 @@ MIDDLEWARE = (
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@ -247,6 +261,7 @@ TEMPLATES = [
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'sekizai.context_processors.sekizai',
# Your stuff: custom template context processors go here
'djconfig.context_processors.config',
],
@ -429,3 +444,9 @@ REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 50
}
# Deprecated need removing, sorl plugin still expects TEMPLATE_DEBUG so for now we need it just for this plugin
TEMPLATE_DEBUG = False
CORS_ORIGIN_WHITELIST = (
'matrix.org'
)

View File

@ -99,3 +99,4 @@ WHITENOISE_AUTOREFRESH = True
WHITENOISE_USE_FINDERS = True
PAYMENT_PROVIDERS['gocardless']['redirect_url'] = 'http://127.0.0.1:8180'
TEMPLATE_DEBUG = False

View File

@ -21,8 +21,9 @@ from mhackspace.blog.sitemaps import PostSitemap, CategorySitemap
from mhackspace.feeds.views import FeedViewSet, ArticleViewSet
from mhackspace.requests.views import RequestsForm, RequestsList
from wiki.urls import get_pattern as get_wiki_pattern
from django_nyt.urls import get_pattern as get_nyt_pattern
# import spirit.urls
router = DefaultRouter()
router.register(r'posts', PostViewSet)
router.register(r'categories', CategoryViewSet)
@ -54,7 +55,7 @@ urlpatterns = [
url(r'^blog/$', PostList.as_view(), name='blog'),
url(r'^blog/rss/$', BlogFeed(), name='blog-rss'),
url(r'^rss.xml$', RssFeed(), name='main-rss'),
url(r'^blog/(?P<slug>[0-9A-Za-z_\-]+)/$', BlogPost.as_view(), name='blog-item'),
url(r'^blog/(?P<slug>[0-9A-Za-z_\-]+)/$', BlogPost.as_view, name='blog-item'),
url(r'^blog/category/(?P<category>[0-9A-Za-z_\-]+)/$', PostList.as_view(), name='blog-category'),
url(r'^blog/category/(?P<category>[0-9A-Za-z_\-]+)/rss/$', BlogCategoryFeed(), name='blog-category-feed'),
url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps},
@ -84,7 +85,10 @@ urlpatterns = [
url(r'^reset/done/$', auth_views.password_reset_complete, name='password_reset_complete'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += [
url(r'^notifications/', get_nyt_pattern()),
url(r'^wiki/', get_wiki_pattern(), name='wiki')
]
if settings.DEBUG:
# This allows the error pages to be debugged during development, just visit
# these url in browser to see how these error pages look like.

View File

@ -5,12 +5,3 @@ from mhackspace.feeds.helper import import_feeds
@shared_task
def update_homepage_feeds():
return import_feeds()
# @task(bind=True)
# @app.on_after_configure.connect
# def setup_periodic_tasks(sender, **kwargs):
# # Executes every Monday morning at 7:30 a.m.
# sender.add_periodic_task(
# crontab(hour=4, minute=0),
# update_homepage_feeds.s(),
# )

View File

View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from django import template
register = template.Library()
@register.filter(name='addcss')
def addcss(field, css):
return field.as_widget(attrs={"class": css})

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-09-04 12:52
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('requests', '0003_userrequests_request_type'),
]
operations = [
migrations.AlterModelOptions(
name='userrequests',
options={'ordering': ('cost',)},
),
migrations.AddField(
model_name='userrequests',
name='cost',
field=models.DecimalField(decimal_places=2, default=0.0, max_digits=4),
preserve_default=False,
),
]

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-09-04 13:10
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):
dependencies = [
('requests', '0004_auto_20170904_1252'),
]
operations = [
migrations.AlterField(
model_name='userrequests',
name='cost',
field=models.DecimalField(decimal_places=2, help_text='Leave blank, if no associated cost, or add estimated cost if not sure.', max_digits=4),
),
migrations.AlterField(
model_name='userrequests',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to=settings.AUTH_USER_MODEL),
),
]

View File

@ -6,17 +6,36 @@ from django.utils import timezone
REQUEST_TYPES = (
(1, 'Equipment request'),
(2, 'Educational request'),
(3, 'Training request'))
(0, 'Equipment request'),
(1, 'Educational request'),
(2, 'Training request'))
class UserRequests(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL, related_name='+')
request_type = models.IntegerField(choices=REQUEST_TYPES)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name='+'
)
request_type = models.IntegerField(choices=REQUEST_TYPES, null=False)
cost = models.DecimalField(
max_digits=4,
decimal_places=2,
help_text='Leave blank, if no associated cost, or add estimated cost if not sure.'
)
description = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
class Meta:
ordering = ('pk',)
ordering = ('cost',)
def request_type_string(self):
return REQUEST_TYPES[self.request_type][1]
# class UserRequestComments(models.Model):
# user = models.OneToOneField(
# settings.AUTH_USER_MODEL, related_name='+')
# comment = models.TextField()
# created_date = models.DateTimeField(default=timezone.now)
# class Meta:
# ordering = ('created_date',)

View File

@ -1,6 +1,7 @@
{% load sass_tags %}
{% load i18n compress %}
{% load static from staticfiles %}
{% load sekizai_tags i18n wiki_tags static %}
<!DOCTYPE html>
<html lang="en">
<head>
@ -83,7 +84,7 @@
<div class="collapse navbar-collapse" id="navbarMainMenu">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="{% url 'home' %}">Home</a>
<a class="nav-link" href="{% url 'home' %}"><span class="fa fa-home" >Home</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'about' %}">About</a>
@ -94,6 +95,12 @@
<li class="nav-item">
<a class="nav-link" href="{% url 'blog' %}">Blog</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'wiki:root' %}">Wiki</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'spirit:index' %}">Forum</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'contact' %}">Contact</a>
</li>
@ -104,17 +111,15 @@
<ul class="nav navbar-nav pull-xs-right">
{% if request.user.is_authenticated %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Member Area
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="{% url 'members' %}">Members</a>
<a class="dropdown-item" href="{# url 'equipment' #}">Equipment</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'users:detail' request.user.username %}">{% trans "My Profile" %}</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Member Area
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="{% url 'users:detail' request.user.username %}">{% trans "My Profile" %}</a>
<a class="dropdown-item" href="{% url 'members' %}">Members</a>
<a class="dropdown-item" href="{% url 'requests' %}">Equipment</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'account_logout' %}">{% trans "Sign Out" %}</a>
@ -148,6 +153,7 @@
<footer class="footer">
<div class="container">
{% block footer-left %}{% endblock footer-left %}
<span class="text-muted">&copy; {% now "Y" %} Maidstone Hackspace</span>
<div class="float-right">
<a href="https://github.com/maidstone-hackspace/" target="_blank"><i class="fa fa-github"></i></a>
@ -181,7 +187,8 @@
ga('send', 'pageview');
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
{% endblock javascript %}
{% endblock javascript %}
{% render_block "js" %}
</body>
</html>

View File

@ -6,32 +6,59 @@
{% block content %}
<h2>Requests</h2>
<div class="row">
<div class="col">
Make a request for equipment you would like to see in the space, request training on equipment or ak a member to run a workshop or talk on something.
<br />
</div>
</div>
{% if form %}
<form method="POST" action="{% url 'requests_form' %}" class="requests_form">
{% csrf_token %}
{{ form|crispy }}
{{ google_capture }}
<button class="btn btn-primary" type="submit" name="action">{% trans "Send" %}</button>
<button class="btn btn-primary " type="submit" name="action">
<span class="fa fa-submit" ></span>
{% trans "Send" %}</button>
</form>
{% endif %}
<table>
{% for request in requests %}
{% else %}
<div class="row">
<div class="col mt-4">
<ul class="nav navbar-nav float-right">
<li class="pull-xs-right" >
<a href="{% url 'requests_form' %}" class="btn btn-primary btn-lg active pull-xs-right" role="button" aria-pressed="true">Request Equipment or Talk</a>
</li>
</ul>
</div>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Type</th>
<th>Date</th>
<th>Detail</th>
</tr>
</thead>
{% for request in requests %}
<tr>
<th scope="row"> {{ forloop.counter }} </th>
<td>
{{ request.type }}
{{ request.request_type }}
{{ request.request_type_string }}
</td>
<td>
{{ request.created_date }}
</td>
<td>
{{ request.description }}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% endif %}
{% endblock content %}
{% block javascript %}

View File

@ -0,0 +1,57 @@
{% extends "base.html" %}
{% load sekizai_tags i18n wiki_tags static %}
{% block content %}
{% block wiki_body %}
<form class="navbar-form navbar-right" id="wiki-search-form" method="GET" action="{% url 'wiki:search' %}">
<div class="input-group">
<input type="search" class="form-control search-query" name="q" placeholder="{% trans "Search wiki..." %}" />
<span class="input-group-btn">
<button class="btn btn-default" type="submit">
<span class="fa fa-search"></span>
</button>
</span>
</div><!-- /input-group -->
</form>
{% block wiki_navbar %}
<div class="navbar navbar-fixed-top navbar-inverse">
<div id="wiki-navbar">
<div class="navbar-right">
{% if user.is_authenticated %}
<ul class="nav navbar-nav">
<li class="dropdown">
<ul class="dropdown-menu">
{% if "wiki.plugins.notifications"|plugin_enabled %}
{% include "wiki/plugins/notifications/menubaritem.html" %}
{% endif %}
{% if "wiki.plugins.globalhistory"|plugin_enabled %}
{% include "wiki/plugins/globalhistory/menubaritem.html" %}
{% endif %}
</ul>
</li>
</ul>
{% endif %}
</div>
{% block wiki_header_navlinks %}{% endblock %}
</div>
</div>
{% endblock %}
<!-- Reserved for breadcrumbs -->
{% block wiki_breadcrumbs %}{% endblock %}
<!-- Main page contents go here -->
{% block wiki_contents %}{% endblock %}
<footer id="wiki-footer">
<hr />
{% block wiki_footer_prepend %}{% endblock %}
</footer>
{% endblock wiki_body %}
{% endblock content %}
{% block javascript %}
{{ block.super }}
<script src="{% static "wiki/js/core.js" %}"></script>
{% endblock javascript %}

View File

@ -0,0 +1,54 @@
{% load i18n wiki_tags %}
{% with selected_tab as selected %}
<li class="nav-item pull-xs-right{% if selected == "settings" %} active{% endif %}">
{% if not user.is_anonymous %}
<a class="nav-link" href="{% url 'wiki:settings' article_id=article.id path=urlpath.path %}" role="button">
<span class="fa fa-wrench"></span>
<span class="hidden-xs">{% trans "Settings" %}</span>
</a>
{% endif %}
</li>
{% for plugin in article_tabs %}
<li class="nav-item pull-xs-right{% if selected == plugin.slug %} active{% endif %}">
<a class="nav-link" href="{% url 'wiki:plugin' slug=plugin.slug article_id=article.id path=urlpath.path %}" role="button">
<span class="{{ plugin.article_tab.1 }}"></span>
<span class="hidden-xs">{{ plugin.article_tab.0 }}</span>
</a>
</li>
{% endfor %}
<li class="nav-item pull-xs-right{% if selected == "history" %} active{% endif %}">
<a class="nav-link" href="{% url 'wiki:history' article_id=article.id path=urlpath.path %}" role="button">
<span class="fa fa-clock-o"></span>
<span class="hidden-xs">{% trans "Changes" %}</span>
</a>
</li>
{% if article|can_write:user and not article.current_revision.locked %}
<li class="nav-item pull-xs-right{% if selected == "edit" %} active{% endif %}">
<a class="nav-link" href="{% url 'wiki:edit' article_id=article.id path=urlpath.path %}" role="button">
<span class="fa fa-edit"></span>
<span class="hidden-xs">{% trans "Edit" %}</span>
</a>
</li>
{% else %}
<li class="nav-item pull-xs-right{% if selected == "source" %} active{% endif %}">
<a class="nav-link" href="{% url 'wiki:source' article_id=article.id path=urlpath.path %}" role="button">
<span class="fa fa-lock"></span>
<span class="hidden-xs">{% trans "View Source" %}</span>
</a>
</li>
{% endif %}
<li class="nav-item pull-xs-right{% if selected == "view" %} active{% endif %}">
<a class="nav-link" href="{% url 'wiki:get' article_id=article.id path=urlpath.path %}" role="button">
<span class="fa fa-home"></span>
<span class="hidden-xs">{% trans "View" %}</span>
</a>
</li>
{% endwith %}

View File

@ -0,0 +1,82 @@
{% load i18n %}
{% if urlpath %}
<div id="article-breadcrumbs">
<ul class="breadcrumb pull-left">
{% for ancestor in urlpath.cached_ancestors %}
<li><a href="{% url 'wiki:get' path=ancestor.path %}">{{ ancestor.article.current_revision.title|truncatechars:25 }}</a></li>
{% endfor %}
<li class="active">{{ article.current_revision.title|truncatechars:25 }}</li>
</ul>
<div class="pull-left" style="margin-left: 10px;">
<div class="btn-group">
<a class="btn btn-info dropdown-toggle" data-toggle="dropdown" href="#" style="padding: 7px;" title="{% trans "Sub-articles for" %} {{ article.current_revision.title }}">
<span class="fa fa-sitemap"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% for child in children_slice %}
<li>
<a href="{% url 'wiki:get' path=child.path %}">
{{ child.article.current_revision.title }}
</a>
</li>
{% empty %}
<li><a href="#"><em>{% trans "No sub-articles" %}</em></a></li>
{% endfor %}
{% if children_slice_more %}
<li><a href="#"><em>{% trans "...and more" %}</em></a></li>
{% endif %}
<li class="divider"></li>
<li>
<a href="{% url 'wiki:dir' path=urlpath.path %}">{% trans "Browse articles in this level" %} &raquo;</a>
</li>
</ul>
</div>
</div>
<div class="pull-left" style="margin-left: 10px;">
<div class="btn-group">
<a class="btn btn-info dropdown-toggle" data-toggle="dropdown" href="#" style="padding: 7px;" title="{% trans "Sub-articles for" %} {{ article.current_revision.title }}">
<span class="fa fa-file"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
{% if urlpath.parent %}
<a href="{% url 'wiki:create' path=urlpath.parent.path %}" style="padding: 7px;">
<span class="fa fa-arrow-right"></span>
{% trans "New article next to" %} {{ article.current_revision.title }}
</a>
{% endif %}
<a href="{% url 'wiki:create' path=urlpath.path %}" style="padding: 7px;">
<span class="fa fa-arrow-down"></span>
{% trans "New article below" %} {{ article.current_revision.title }}
</a>
</li>
</ul>
</div>
</div>
{% if user.is_superuser %}
<div class="pull-left" style="margin-left: 10px;">
<div class="btn-group">
<a class="btn btn-info dropdown-toggle" data-toggle="dropdown" href="#" style="padding: 7px;" title="{% trans "Sub-articles for" %} {{ article.current_revision.title }}">
<span class="fa fa-cogs"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% if user.is_superuser %}
<li>
<a href="{% url 'wiki:deleted_list' %}">
<i class="fa fa-trash-o"></i>
{% trans "Deleted articles" %}
</a>
</li>
{% endif %}
</ul>
</div>
</div>
{% endif %}
<div style="clear: both"></div>
</div>
{% endif %}

View File

@ -0,0 +1,29 @@
{% load addcss %}
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="form-group{% if field.errors %} has-error{% endif %}">
<div class="wiki-label col-xs-3 col-lg-2">
{% if field.label %}
<label for="{{ field.id_for_label }}" class="form-control-label {% if field.field.required %}requiredField{% endif %}">
{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
{{ field.label|safe }}
</label>
{% endif %}
</div>
<div class="wiki-control col-xs-9 col-lg-10">
{{ field|addcss:"form-control form-control-danger danger" }}
{% if field.errors %}
{% for error in field.errors %}
<div class="form-control-feedback" id="error_{{ forloop.counter }}_{{ field.auto_id }}">
{{ error }}
</div>
{% endfor %}
{% endif %}
{% if field.help_text %}
<small id="hint_{{ field.auto_id }}" class="form-text text-muted">{{ field.help_text|safe }}</small>
{% endif %}
</div>
</div>
{% endif %}

View File

@ -1,8 +1,8 @@
# from celery import shared_task
# from mhackspace.subscriptions.management.commands.update_membership_status import update_subscriptions
from celery import shared_task
from mhackspace.subscriptions.management.commands.update_membership_status import update_subscriptions
# @shared_task
# def update_users_memebership_status():
# for user in update_subscriptions(provider_name='gocardless'):
# continue
@shared_task
def update_users_memebership_status():
for user in update_subscriptions(provider_name='gocardless'):
continue

View File

@ -58,6 +58,7 @@ braintree==3.37.2
django-autofixture==0.12.1
git+https://github.com/olymk2/scaffold.git
git+git://github.com/django-wiki/django-wiki.git
djangorestframework==3.6.3
django-filter==1.0.2
@ -74,3 +75,4 @@ celery==4.1.0
django-celery-results==1.0.1
django-celery-beat==1.0.1
django-cors-headers