Skip to content

Commit

Permalink
Finish v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Doca committed Sep 16, 2015
2 parents 781d07d + 017306d commit d9dc671
Show file tree
Hide file tree
Showing 48 changed files with 1,166 additions and 3,461 deletions.
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,22 @@ https://github.com/volunteer-planner/volunteer_planner/wiki/DevelopmentRules

sudo apt-get install python-dev python-pip git npm

This will install Python libraries and Git.

If you are going to use a local mysql server, additionally install

sudo apt-get install libmysqlclient-dev mysql-client mysql-server

This will install MySQL server, Python libraries and Git. It will ask you to set a root password [ROOT_PASSWORD] for
the mysql server, if you haven't already set up MySQL in the past. Remember the password.
This will install MySQL server, it will ask you to set a root password
[ROOT_PASSWORD] for the mysql server, if you haven't already set up MySQL in the
past. Remember the password.

### 2. Clone the repository

git clone https://github.com/volunteer-planner/volunteer_planner.git

An instance of the volunteer_planner will be created in the folder `volunteer_planner`.
An instance of the volunteer_planner will be created in the folder
`volunteer_planner`.

### 3. Create a virtual environment

Expand All @@ -34,7 +38,9 @@ bash

source volunteer_planner-venv/bin/activate (for bash) or

fish . volunteer_planner-venv/bin/activate.fish
fish

. volunteer_planner-venv/bin/activate.fish

### 4. Install all requirements by running

Expand All @@ -59,11 +65,10 @@ or, if you intend to use mysql locally, install
*Note*: For the local environment, the DB username is assumed to be 'vp'
and their password is assumed to be 'volunteer_planner'.

### 6. Create local runner
### 6. Setup your local environment (optional)

cp man.py manlocal.py

Edit the file and update values for db credentials, settings file (volunteer_planner.settings.local[_mysql]) and the rest with your preferred settings.
If you need to use non-default settings values, setup the environment variables
in your virtualenv's (post-)activation hooks or your IDE's project settings.

### 7. Initialize the database

Expand All @@ -73,7 +78,8 @@ Edit the file and update values for db credentials, settings file (volunteer_pla

./manlocal.py createsuperuser

You will be asked for username, email and password (twice). Remember that username and password.
You will be asked for username, email and password (twice). Remember that
username and password.

### 9. Try running the server

Expand All @@ -83,13 +89,15 @@ Try opening http://localhost:8000/ in your browser.

### 9. Adding content

To add new organizations and shifts, you have to access the backend at `http://localhost:8000/admin`.
If prompted, login with the username/password of the superuser you created earlier (in case you don't see an error page here).
To add new organizations and shifts, you have to access the backend at
`http://localhost:8000/admin`. If prompted, login with the username/password of
the superuser you created earlier (in case you don't see an error page here).

http://localhost:8000/admin`

## The Project

We use less for precompiling css. The less file you will find in scheduler/static/bootstrap/less/project.less

To make this work you can just initialize the folder with "npm install -g" and then let grunt watch for changes.
We use less for precompiling css. The less file you will find in
`scheduler/static/bootstrap/less/project.less` To make this work you can just
initialize the folder with "npm install -g" and then let grunt watch for
changes.
2 changes: 1 addition & 1 deletion account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AccountUpdateView(LoginRequiredMixin, UpdateView):
"""
Allows a user to update their profile.
"""
fields = ['first_name', 'last_name', 'email']
fields = ['first_name', 'last_name']
template_name = "user_account_edit.html"
success_url = reverse_lazy('account_detail')

Expand Down
11 changes: 11 additions & 0 deletions blueprint/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django import forms

from .models import BluePrintCreator, NeedBluePrint


Expand All @@ -20,6 +21,16 @@ class BluePrintCreatorAdmin(admin.ModelAdmin):
form = BluePrintCreatorAdminForm
filter_horizontal = ('needs',)

fieldsets = (
(None, {
'fields': ('title', 'location')
}),
(None, {
'classes': ('needs_in_blueprint',),
'fields': ('needs',)
}),
)


class NeedBluePrintAdmin(admin.ModelAdmin):
list_display = ['topic', 'get_location']
Expand Down
43 changes: 23 additions & 20 deletions blueprint/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# coding: utf-8

import json

from django.http.response import HttpResponse
from django.shortcuts import render
from django.views.generic import TemplateView
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import user_passes_test
from scheduler.models import Location, Need, Topics, TimePeriods

from dateutil.parser import parse
from .models import BluePrintCreator, NeedBluePrint

from scheduler.models import Location, Need
from .models import BluePrintCreator


class SuperuserRequiredMixin(object):
Expand Down Expand Up @@ -34,24 +38,23 @@ def generate_blueprint(request):
blueprint = BluePrintCreator.objects.get(location=location)
message = []
for need in blueprint.needs.all():
time_from = parse(request.POST.get('date') + " " + need.from_time, ignoretz=True, fuzzy=True)
time_to = parse(request.POST.get('date') + " " + need.to_time, ignoretz=True, fuzzy=True)
if Need.objects.filter(topic=need.topic, location=location, time_period_from__date_time=str(time_from),
time_period_to__date_time=str(time_to)).count() > 0:
time_from = parse(
request.POST.get('date') + " " + need.from_time,
ignoretz=True, fuzzy=True)
time_to = parse(request.POST.get('date') + " " + need.to_time,
ignoretz=True, fuzzy=True)

# TODO: remove string casting dates here??
if Need.objects.filter(topic=need.topic,
location=location,
starting_time=str(time_from),
ending_time=str(time_to)).count() > 0:
message.append('Ist bereits vorhanden')
else:
time_to_link = TimePeriods(date_time=time_to)
time_to_link.save()
time_from_link = TimePeriods(date_time=time_from)
time_from_link.save()
new_need = Need(
topic=need.topic,
location=location,
time_period_from=time_from_link,
time_period_to=time_to_link,
slots=need.slots
)
new_need.save()
Need.objects.create(topic=need.topic, location=location,
starting_time=time_from,
ending_time=time_to, slots=need.slots)
message.append('Ist angelegt worden!')

return HttpResponse(json.dumps({"data": message}), content_type="application/json")
return HttpResponse(json.dumps({"data": message}),
content_type="application/json")
43 changes: 43 additions & 0 deletions common/conf_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: utf-8
import os


# TODO: tests & docstring
class ConfLoader(object):
class ConfigNotFound(Exception):
def __init__(self, key):
self.key = key

@property
def message(self):
return u"ConfigNotFound: {}".format(self.key)

def __init__(self, settings=None, env_fmt=None, env=True,
raise_missing=True, **defaults):
self._defaults = defaults or {}
self.env = env
self.env_fmt = env_fmt or "{}"
self.raise_missing = raise_missing
self.settings = settings

def _get_from_env(self, key):
env_key = self.env_fmt.format(key)
return os.environ.get(env_key, None)

# TODO: caching?
def __getitem__(self, item):
try:
if self.settings and hasattr(self.settings, item):
return getattr(self.settings, item)
elif self.env:
env_value = self._get_from_env(item)
if env_value is not None:
return env_value
return self._defaults[item]
except KeyError:
if self.raise_missing:
raise ConfLoader.ConfigNotFound(item)
return None

def __getattr__(self, key):
return self[key]
1 change: 1 addition & 0 deletions google_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# coding: utf-8
22 changes: 22 additions & 0 deletions google_tools/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# coding: utf-8

from django.conf import settings

from common.conf_loader import ConfLoader


def google_tools_config(request):
config = ConfLoader(settings, raise_missing=False)

google_tools = dict()

if config.GOOGLE_SITE_VERIFICATION: # and not settings.DEBUG:
google_tools['site_verification'] = config.GOOGLE_SITE_VERIFICATION

if config.GOOGLE_ANALYTICS_TRACKING_ID: # and not settings.DEBUG:
google_tools['analytics'] = {
'tracking_id': config.GOOGLE_ANALYTICS_TRACKING_ID,
'domain': config.GOOGLE_ANALYTICS_DOMAIN
}

return dict(google_tools=google_tools)
19 changes: 19 additions & 0 deletions google_tools/templates/google_headers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% if google_tools %}{% if google_tools.site_verification %}
<meta name="google-site-verification" content="{{ google_tools.site_verification }}"/>
{% endif %}{% if google_tools.analytics %}
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', '{{ google_tools.analytics.tracking_id }}', '{{ google_tools.analytics.domain|default:"auto" }}');
ga('send', 'pageview');
</script>{% endif %}{% endif %}
46 changes: 17 additions & 29 deletions locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-14 10:29+0200\n"
"POT-Creation-Date: 2015-09-16 12:32+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -131,60 +131,48 @@ msgstr "Schicht"
msgid "shifts"
msgstr "Schichten"

#: scheduler/models.py:20 scheduler/models.py:90
#: scheduler/models.py:20 scheduler/models.py:67
msgid "helptype"
msgstr "Hilfebereich"

#: scheduler/models.py:20
msgid "helptype_text"
msgstr "Jeder Hilfebereich hat so viele Planelemente wie es Arbeitsschichten geben soll. Dies ist EINE Arbeitsschicht für einen bestimmten Tag"

#: scheduler/models.py:21 scheduler/models.py:125
#: scheduler/models.py:21 scheduler/models.py:90
msgid "location"
msgstr "Ort"

#: scheduler/models.py:23
msgid "starting time"
msgstr "Beginn"

#: scheduler/models.py:24
msgid "time from"
msgstr "Anfangszeit"
msgid "ending time"
msgstr "Ende"

#: scheduler/models.py:29
#: scheduler/models.py:28
msgid "number of needed volunteers"
msgstr "Anz. benötigter Freiwillige"

#: scheduler/models.py:34
msgid "assigned volunteers"
msgstr "Reg. Freiwillige"

#: scheduler/models.py:39
msgid "volunteers"
msgstr "Freiwillige"

#: scheduler/models.py:91
#: scheduler/models.py:68
msgid "helptypes"
msgstr "Hilfebereiche"

#: scheduler/models.py:106
msgid "timeperiod"
msgstr "Zeitspanne"

#: scheduler/models.py:107
msgid "timeperiods"
msgstr "Zeitspannen"

#: scheduler/models.py:126
#: scheduler/models.py:91
msgid "locations"
msgstr "Orte"

#: scheduler/views.py:79
#: scheduler/views.py:84
msgid "The submitted data was invalid."
msgstr "Die eingegebenen Daten sind ungültig."

#: scheduler/views.py:90
#: scheduler/views.py:97
#, python-brace-format
msgid "We can't add you to this shift because you've already agreed to other shifts at the same time: {conflicts}"
msgstr "Sie können der Schicht nicht beitreten, da Sie bereits an anderen mit überschneidenden Zeiten teilnehmen: {conflicts}"

#: scheduler/views.py:93
#: scheduler/views.py:102
msgid "You were successfully added to this shift."
msgstr "Sie haben sich erfolgreich für die Schicht angemeldet."

Expand All @@ -208,11 +196,11 @@ msgstr "Organisation"
msgid "email"
msgstr "E-Mail"

#: volunteer_planner/settings/base.py:130
#: volunteer_planner/settings/base.py:131
msgid "German"
msgstr "Deutsch"

#: volunteer_planner/settings/base.py:131
#: volunteer_planner/settings/base.py:132
msgid "English"
msgstr "Englisch"

Expand Down
18 changes: 0 additions & 18 deletions man.py

This file was deleted.

Loading

0 comments on commit d9dc671

Please sign in to comment.