Skip to content
This repository was archived by the owner on Jan 4, 2020. It is now read-only.

Commit

Permalink
OpenSlides protocol plugin 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnStutzenstein committed Aug 4, 2017
1 parent 2b71141 commit aa16cda
Show file tree
Hide file tree
Showing 40 changed files with 2,570 additions and 491 deletions.
19 changes: 12 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@

# Python compiled files
*.pyc
__pycache__/

# Development user data (settings, database, media, search index)
settings.py
database.sqlite
media/
whoosh_index/
# Local user data (settings, database, media, search index, static files)
personal_data/*

# Javascript tools and libraries
node_modules/*
bower_components/*

# Package building
*.egg-info
build/
dist/
build/*
dist/*

# Temporary files
*.swp
*~
.DS_Store

# Staticfiles
openslides_protocol/static/*
26 changes: 20 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
language: python
sudo: false
cache:
pip: true
yarn: true
python:
- "2.6"
- "2.7"
- "3.5"
- "3.6"
env:
- TRAVIS_NODE_VERSION="4"
before_install:
- nvm install $TRAVIS_NODE_VERSION
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
install:
- "pip install -r requirements.txt"
- "pip install flake8==2.1.0"
- pip install --upgrade setuptools pip
- pip install -r requirements.txt
- pip freeze
- yarn
script:
- "PYTHONPATH=$PYTHONPATH DJANGO_SETTINGS_MODULE=tests.settings openslides django test"
- "flake8 --max-line-length=150 openslides_protocol tests"
- node_modules/.bin/gulp jshint
- isort --check-only --recursive openslides_protocol tests
- flake8 openslides_protocol tests
- PYTHONPATH=./ DJANGO_SETTINGS_MODULE='tests.settings' openslides test
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ contribution:

* Norman Jäckel <[email protected]>
* Emanuel Schütze <[email protected]>
* Finn Stutzenstein <[email protected]>
7 changes: 7 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "openslides-protocol",
"private": true,
"dependencies": {
"angular-gettext": "~2.3.6"
}
}
66 changes: 66 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Run tasks with $ ./node_modules/.bin/gulp
require('es6-promise').polyfill();

var gulp = require('gulp'),
gettext = require('gulp-angular-gettext'),
jshint = require('gulp-jshint'),
path = require('path'),
templateCache = require('gulp-angular-templatecache');

/**
* Default tasks to be run before start.
*/

// Catches all template files concats them to one file js/templates.js.
gulp.task('templates', function () {
return gulp.src(path.join('**', 'static', 'templates', '**', '*.html'))
.pipe(templateCache('templates.js', {
module: 'OpenSlidesApp.openslides_protocol.templates',
standalone: true,
moduleSystem: 'IIFE',
transformUrl: function (url) {
var pathList = url.split(path.sep);
pathList.shift();
return pathList.join(path.sep);
},
}))
.pipe(gulp.dest(path.join('static', 'js', 'openslides_protocol')));
});
// Compiles translation files (*.po) to *.json and saves them in the directory 'i18n'.
gulp.task('translations', function () {
return gulp.src(path.join('openslides_protocol', 'locale', 'angular-gettext', '*.po'))
.pipe(gettext.compile({
format: 'json'
}))
.pipe(gulp.dest(path.join('static', 'i18n', 'openslides_protocol')));
});

// Gulp default task. Runs all other tasks before.
gulp.task('default', ['translations', 'templates'], function () {});


/**
* Extra tasks that have to be called manually. Useful for development.
*/

// Extracts translatable strings using angular-gettext and saves them in file
// locale/angular-gettext/template-en.pot.
gulp.task('pot', function () {
return gulp.src([
'openslides_protocol/static/templates/*/*.html',
'openslides_protocol/static/js/*/*.js',
])
.pipe(gettext.extract('template-en.pot', {}))
.pipe(gulp.dest(path.join('openslides_protocol', 'locale', 'angular-gettext')));
});

// Checks JavaScript using JSHint
gulp.task('jshint', function () {
return gulp.src([
'gulpfile.js',
path.join('openslides_protocol', 'static', 'js', 'openslides_protocol', '*.js'),
])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
16 changes: 3 additions & 13 deletions openslides_protocol/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
# -*- coding: utf-8 -*-

from inspect import stack

for frame in stack():
lines = frame[4]
if lines and 'Peikee0iuv7uhikuashotohch6eec6ohseuNg7su' in lines[0]:
break
else:
from . import main_menu, signals # noqa
from .urls import urlpatterns # noqa

__verbose_name__ = 'OpenSlides Protocol Plugin'
__description__ = 'This plugin for OpenSlides provides a protocol of events managed in OpenSlides.'
__version__ = '1.0-dev'
__version__ = '2.0-dev'

default_app_config = 'openslides_protocol.apps.ProtocolAppConfig'
15 changes: 15 additions & 0 deletions openslides_protocol/access_permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from openslides.utils.access_permissions import BaseAccessPermissions
from openslides.utils.auth import has_perm


class ItemProtocolAccessPermissions(BaseAccessPermissions):
"""
Access permissions for ItemProtocol and the ViewSet.
"""
def check_permissions(self, user):
return has_perm(user, 'openslides_protocol.can_write_protocol')

def get_serializer_class(self, user=None):
from .serializers import ItemProtocolSerializer

return ItemProtocolSerializer
57 changes: 57 additions & 0 deletions openslides_protocol/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os

from django.apps import AppConfig
from openslides.utils.collection import Collection

from . import __description__, __verbose_name__, __version__


class ProtocolAppConfig(AppConfig):
name = 'openslides_protocol'
verbose_name = __verbose_name__
description = __description__
version = __version__
angular_site_module = True
js_files = [
'static/js/openslides_protocol/base.js',
'static/js/openslides_protocol/site.js',
'static/js/openslides_protocol/templates.js', # This file has a different basefolder!
]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

try:
import settings
except ImportError:
# When testing, we cannot import settings here..
pass
else:
# Add the staticfiles dir to OpenSlides
base_path = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
# remove the app folder 'openslides_protcol'
base_path = os.path.dirname(base_path)
settings.STATICFILES_DIRS.append(os.path.join(base_path, 'static'))

def ready(self):
# Load projector elements.
# Do this by just importing all from these files.
from . import projector # noqa

# Import all required stuff.
from openslides.core.signals import post_permission_creation
from openslides.utils.rest_api import router
from .signals import add_permissions_to_builtin_groups
from .views import ItemProtocolViewSet

# Connect signals.
post_permission_creation.connect(
add_permissions_to_builtin_groups,
dispatch_uid='protocol_add_permissions_to_builtin_groups'
)

# Register viewsets.
router.register(self.get_model('ItemProtocol').get_collection_string(), ItemProtocolViewSet)

def get_startup_elements(self):
yield Collection(self.get_model('ItemProtocol').get_collection_string())
14 changes: 0 additions & 14 deletions openslides_protocol/forms.py

This file was deleted.

53 changes: 53 additions & 0 deletions openslides_protocol/locale/angular-gettext/template-en.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Project-Id-Version: \n"

#: openslides_protocol/item-protocol-form.html:16
#: openslides_protocol/protocol-list.html:45
msgid "Are you sure to delete this protocol?"
msgstr ""

#: openslides_protocol/item-protocol-form.html:13
msgid "Cancel"
msgstr ""

#: openslides_protocol/agenda-hook.html:5
#: openslides_protocol/item-protocol-form.html:2
msgid "Create protocol"
msgstr ""

#: openslides_protocol/item-protocol-form.html:18
#: openslides_protocol/protocol-list.html:45
msgid "Delete"
msgstr ""

#: openslides_protocol/protocol-list.html:42
msgid "Edit"
msgstr ""

#: openslides_protocol/agenda-hook.html:4
#: openslides_protocol/item-protocol-form.html:1
msgid "Edit protocol"
msgstr ""

#: openslides_protocol/protocol-list.html:25
msgid "Item"
msgstr ""

#: openslides_protocol/protocol-list.html:17
#: openslides_protocol/protocol-list.html:26
#: openslides_protocol/site.js:14
#: openslides_protocol/site.js:26
#: openslides_protocol/site.js:82
msgid "Protocol"
msgstr ""

#: openslides_protocol/item-protocol-form.html:10
msgid "Save"
msgstr ""

#: openslides_protocol/protocol-list.html:14
msgid "Select all"
msgstr ""
Binary file removed openslides_protocol/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
55 changes: 0 additions & 55 deletions openslides_protocol/locale/de/LC_MESSAGES/django.po

This file was deleted.

Loading

0 comments on commit aa16cda

Please sign in to comment.