Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings #245

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('notification_center', '0010_auto_20150218_1735'),
]

operations = [
migrations.AddField(
model_name='notificationevent',
name='description',
field=models.CharField(default='no descriptioN', max_length=50),
preserve_default=False,
),
]
2 changes: 2 additions & 0 deletions tweap/notification_center/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

class NotificationEvent(models.Model):
text = models.CharField(max_length=50, null=False)
# is shown in settings pane
description = models.CharField(max_length=50, null=False)

def __str__(self):
return self.text
Expand Down
Empty file added tweap/settings/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions tweap/settings/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Empty file.
21 changes: 21 additions & 0 deletions tweap/settings/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.db import models
from django.contrib.auth.models import User
from project_management.models import Project
from notification_center.models import NotificationEvent


class NotificationSetting(models.Model):
event = models.ForeignKey(NotificationEvent, null=False)
setting = models.CharField(max_length=50, null=False) # email, dashboard, multiple
user = models.ForeignKey(User, null=False)


class ProjectOrder(models.Model):
project = models.ForeignKey(Project, null=False)
user = models.ForeignKey(User, null=False)
order_number = models.IntegerField(null=False)


class LanguagePreference(models.Model):
primary_language = models.CharField(max_length=20, null=False)
user = models.ForeignKey(User, null=False)
94 changes: 94 additions & 0 deletions tweap/settings/templates/settings/settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{% extends "project_management_template.html" %}
{% load i18n %}
{% block js %}
<script>
$(function() {
$("#sortable").sortable({
stop: function(event, ui) {
givePositionalNumbers();
}
});
$( "#sortable" ).disableSelection();
});

function givePositionalNumbers() {
var count = 0;
$('.ui-state-default').each(function(){
console.log(count + ". " + $(this).text());
count++;
});
}
</script>
{% endblock %}
{% block project_management_template %}
<div class="well well-lg panel col-md-8 col-md-offset-2">
<div class="row col-md-12">
<h1>{% trans "Settings" %}</h1>
</div>

<div class="row col-md-12">
<h2>Notification Settings</h2>
<p class="lead">Tell us how you want to be notified about new events!</p>
<div class="list-group col-md-12">
{% for type in event_types %}
<div class="list-group-item">
{{ type.description }} <br>
<label>
<input type="checkbox" value="email" checked>
Via Email
</label>
<label>
<input type="checkbox" value="dashboard" checked>
In the dashboard
</label>
</div>
{% endfor %}
<div class="list-group-item">
For a todo that's due today <br>
<label>
<input type="checkbox" value="email" checked>
Via Email
</label>
</div>
<div class="list-group-item">
For an upcoming Event <br>
<label>
<input type="checkbox" value="email" checked>
Via Email
</label>
</div>
</div>
</div>

<div class="row col-md-12">
<h2>Project Order</h2>
<p class="lead">Order your projects, so whenever there's a list of your projects, this order will be kept.</p>

<ul id="sortable" class="list-group col-md-12" style="cursor: move;">
{% for project in projects %}
<li class="ui-state-default list-group-item"><span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span> {{project.name}}</li>
{% endfor %}
</ul>
</div>
<div class="row col-md-12">
<h2>Language Preference</h2>
<p class="lead">No matter from where you connect, your tweap will always be in this language.</p>
<label>
<input type="radio" name="language" id="optionsRadios1" value="option1" checked>
English
</label>
<br>
<label>
<input type="radio" name="language" id="optionsRadios2" value="option2">
Deutsch
</label>
<br>
<label>
<input type="radio" name="language" id="optionsRadios3" value="option3">
Polski
</label>
</div>

<button class="btn btn-success" style="margin-top: 12px;">Save Changes</button>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions tweap/settings/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions tweap/settings/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.conf.urls import patterns, url
from settings import views

urlpatterns = patterns(
'',
url(r'^$', views.Settings.as_view(), name='settings'),
)
14 changes: 14 additions & 0 deletions tweap/settings/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.shortcuts import render
from django.views.generic import View
from project_management.models import Project
from notification_center.models import NotificationEvent

class Settings(View):

def get(self, request):
user = request.user

projects = Project.objects.filter(members=user)
event_types = NotificationEvent.objects.all()
context = {'projects': projects, 'event_types': event_types}
return render(request, 'settings/settings.html', context)
152 changes: 152 additions & 0 deletions tweap/tweap/DEPLOYMENT_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
"""
Django settings for tweap project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
from easy_thumbnails.conf import Settings as ThumbnailSettings
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '3gtff-keg7%50ieg1kf(#k$^g*8bgh^kwq43vavkzon^#5dm1r'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'
#TODO: ja, hier muss irgendwie der lokale Pfad vom Server stehen

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'user_management',
'project_management',
'rosetta',
'image_cropping',
'easy_thumbnails',
'dashboard',
'settings',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'tweap.middleware.RequireLoginMiddleware',
)

ROOT_URLCONF = 'tweap.urls'

WSGI_APPLICATION = 'tweap.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'tweap',
'USER': 'root',
'PASSWORD': 'tweap',
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/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.7/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR + "/tweap/", 'static'),
)

STATIC_ROOT = "/home/goggelz/STATIC_DJANGO/tweap/"

TEMPLATE_DIRS = (
os.path.join(BASE_DIR + "/tweap/", 'templates'),
)

# non standard values

LOGIN_REDIRECT_URL = 'dashboard:home'

LOGIN_URL = 'user_management:login'

LOGIN_REQUIRED_URLS = (
r'/projects/(.*)$',
r'/users/profile/(.*)$',
r'/users/editprofile/$',
r'/settings/$',
)

LOGIN_REQUIRED_URLS_EXCEPTIONS = (
r'/users/login$',
)

LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)

LANGUAGES = (
("en", "English"),
("de", "Deutsch"),
("pl", "Polski"),
)

THUMBNAIL_PROCESSORS = (
'image_cropping.thumbnail_processors.crop_corners',
) + ThumbnailSettings.THUMBNAIL_PROCESSORS

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"django.contrib.auth.context_processors.auth",
"user_management.context_processors.user_info"
)
4 changes: 3 additions & 1 deletion tweap/tweap/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'cal',
'debug_toolbar',
'chat',
'settings',
)

MIDDLEWARE_CLASSES = (
Expand Down Expand Up @@ -126,6 +127,7 @@
r'/users/profile/(.*)$',
r'/users/editprofile/$',
r'/users/user_suggestion/$',
r'/settings/$',
)

LOGIN_REQUIRED_URLS_EXCEPTIONS = (
Expand Down Expand Up @@ -155,4 +157,4 @@
"django.contrib.messages.context_processors.messages",
"django.contrib.auth.context_processors.auth",
"user_management.context_processors.user_info"
)
)
Loading