From 535214508e1e01202daf66d189c739e35ed1ffb4 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Tue, 16 Aug 2016 15:49:29 +0200 Subject: [PATCH 01/29] add dashboard --- euth/dashboard/__init__.py | 0 euth/dashboard/apps.py | 6 ++ .../euth_dashboard/base_dashboard.html | 56 +++++++++++++++++++ .../euth_dashboard/dashboard_overview.html | 6 ++ .../euth_dashboard/profile_detail.html | 6 ++ euth/dashboard/templatetags/__init__.py | 0 .../templatetags/dashboard_templatetags.py | 11 ++++ euth/dashboard/urls.py | 10 ++++ euth/dashboard/views.py | 11 ++++ euth_wagtail/settings/base.py | 1 + euth_wagtail/static/scss/all.scss | 1 + .../static/scss/components/_dashboard.scss | 40 +++++++++++++ euth_wagtail/urls.py | 2 + tests/rates/test_rate_models.py | 1 - 14 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 euth/dashboard/__init__.py create mode 100644 euth/dashboard/apps.py create mode 100644 euth/dashboard/templates/euth_dashboard/base_dashboard.html create mode 100644 euth/dashboard/templates/euth_dashboard/dashboard_overview.html create mode 100644 euth/dashboard/templates/euth_dashboard/profile_detail.html create mode 100644 euth/dashboard/templatetags/__init__.py create mode 100644 euth/dashboard/templatetags/dashboard_templatetags.py create mode 100644 euth/dashboard/urls.py create mode 100644 euth/dashboard/views.py create mode 100644 euth_wagtail/static/scss/components/_dashboard.scss diff --git a/euth/dashboard/__init__.py b/euth/dashboard/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/euth/dashboard/apps.py b/euth/dashboard/apps.py new file mode 100644 index 000000000..9a25d8af6 --- /dev/null +++ b/euth/dashboard/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DashboardConfig(AppConfig): + name = 'euth.dashboard' + label = 'euth_dashboard' diff --git a/euth/dashboard/templates/euth_dashboard/base_dashboard.html b/euth/dashboard/templates/euth_dashboard/base_dashboard.html new file mode 100644 index 000000000..886a50d2b --- /dev/null +++ b/euth/dashboard/templates/euth_dashboard/base_dashboard.html @@ -0,0 +1,56 @@ +{% extends "base.html" %} +{% load i18n dashboard_templatetags %} + + +{% block content %} +
+
+
+
+
+ {% url 'dashboard-overview' as dashboard_overview %} + +

+ {% trans 'Overview' %} +

+
+ + {% url 'dashboard-profile' as dashboard_profile %} + +

+ {% trans 'Profile' %} +

+
+
+
+
+
+
+ {% block dashboard_content %} + {% endblock %} +
+
+
+
+ + +{% endblock %} diff --git a/euth/dashboard/templates/euth_dashboard/dashboard_overview.html b/euth/dashboard/templates/euth_dashboard/dashboard_overview.html new file mode 100644 index 000000000..939fed818 --- /dev/null +++ b/euth/dashboard/templates/euth_dashboard/dashboard_overview.html @@ -0,0 +1,6 @@ +{% extends "euth_dashboard/base_dashboard.html" %} +{% load i18n %} + +{% block dashboard_content %} +

{% trans 'Overview' %}

+{% endblock %} diff --git a/euth/dashboard/templates/euth_dashboard/profile_detail.html b/euth/dashboard/templates/euth_dashboard/profile_detail.html new file mode 100644 index 000000000..a7777158e --- /dev/null +++ b/euth/dashboard/templates/euth_dashboard/profile_detail.html @@ -0,0 +1,6 @@ +{% extends "euth_dashboard/base_dashboard.html" %} +{% load i18n %} + +{% block dashboard_content %} +

{% trans 'Profile' %}

+{% endblock %} diff --git a/euth/dashboard/templatetags/__init__.py b/euth/dashboard/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/euth/dashboard/templatetags/dashboard_templatetags.py b/euth/dashboard/templatetags/dashboard_templatetags.py new file mode 100644 index 000000000..6fb5eefef --- /dev/null +++ b/euth/dashboard/templatetags/dashboard_templatetags.py @@ -0,0 +1,11 @@ +from django import template + +register = template.Library() + + +@register.simple_tag +def selected(request, pattern): + path = request.path + if path == pattern: + return 'selected' + return '' diff --git a/euth/dashboard/urls.py b/euth/dashboard/urls.py new file mode 100644 index 000000000..7d8b3ed75 --- /dev/null +++ b/euth/dashboard/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url(r'profile/$', + views.DashboardProfileView.as_view(), name='dashboard-profile'), + url(r'', + views.DashboardOverviewView.as_view(), name='dashboard-overview'), +] diff --git a/euth/dashboard/views.py b/euth/dashboard/views.py new file mode 100644 index 000000000..29ac33116 --- /dev/null +++ b/euth/dashboard/views.py @@ -0,0 +1,11 @@ +from django.views import generic + + +class DashboardProfileView(generic.TemplateView): + + template_name = "euth_dashboard/profile_detail.html" + + +class DashboardOverviewView(generic.TemplateView): + + template_name = "euth_dashboard/dashboard_overview.html" diff --git a/euth_wagtail/settings/base.py b/euth_wagtail/settings/base.py index 567a5bbe9..e4ec20db9 100644 --- a/euth_wagtail/settings/base.py +++ b/euth_wagtail/settings/base.py @@ -71,6 +71,7 @@ 'euth.modules.apps.ModuleConfig', 'euth.ideas.apps.IdeaConfig', 'euth.rates.apps.RatesConfig', + 'euth.dashboard.apps.DashboardConfig' ] MIDDLEWARE_CLASSES = [ diff --git a/euth_wagtail/static/scss/all.scss b/euth_wagtail/static/scss/all.scss index 6b640b9f8..69e8f00e1 100644 --- a/euth_wagtail/static/scss/all.scss +++ b/euth_wagtail/static/scss/all.scss @@ -31,3 +31,4 @@ @import "scss/components/forms"; @import "scss/components/avatars"; @import "scss/components/ideas"; +@import "scss/components/dashboard"; diff --git a/euth_wagtail/static/scss/components/_dashboard.scss b/euth_wagtail/static/scss/components/_dashboard.scss new file mode 100644 index 000000000..9b282fcba --- /dev/null +++ b/euth_wagtail/static/scss/components/_dashboard.scss @@ -0,0 +1,40 @@ +.dashboard { + @include rem(padding, 113px 0px 0px 0px); +} + +.dashboard-nav { + + & a, a:active, a:focus, a:visited { + text-decoration: none; + } + + & .list-group-item-heading { + background-color: $gray-lighter; + @include rem(padding, 20px 0px 20px 60px); + margin: 0px; + @include rem(font-size, 14px); + color: $black; + + i { + color: $gray; + } + } + + & .selected { + background-color: white; + color: $brand-brand1; + text-decoration: none; + + i { + color: $brand-brand1; + } + } +} + +.dashboard-content { + & h1 { + margin: 0px; + @include rem(font-size, 30px); + } +} + diff --git a/euth_wagtail/urls.py b/euth_wagtail/urls.py index 614da3271..ad5cfa616 100644 --- a/euth_wagtail/urls.py +++ b/euth_wagtail/urls.py @@ -10,6 +10,7 @@ from wagtail.wagtaildocs import urls as wagtaildocs_urls from euth.comments.api import CommentViewSet +from euth.dashboard import urls as dashboard_urls from euth.ideas import urls as ideas_urls from euth.organisations import urls as organisations_urls from euth.projects import urls as projects_urls @@ -34,6 +35,7 @@ urlpatterns += i18n_patterns( url(r'', include(user_urls)), + url(r'^dashboard/', include(dashboard_urls)), url(r'^orgs/', include(organisations_urls)), url(r'^projects/', include(projects_urls)), url(r'^ideas/', include(ideas_urls)), diff --git a/tests/rates/test_rate_models.py b/tests/rates/test_rate_models.py index 2ac439c2b..a1393df6b 100644 --- a/tests/rates/test_rate_models.py +++ b/tests/rates/test_rate_models.py @@ -1,5 +1,4 @@ import pytest - from django.db import IntegrityError From 39522487a8fb6ce008d46f3e98c9c046bf0d6649 Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Wed, 17 Aug 2016 10:52:25 +0200 Subject: [PATCH 02/29] make hero unit more like design --- .../templates/euth_projects/project_detail.html | 8 +++++++- euth_wagtail/settings/base.py | 1 + euth_wagtail/static/scss/components/_orgs.scss | 13 +++++++++++++ .../static/scss/core/_bootstrap-variables.scss | 3 ++- euth_wagtail/static/scss/core/_hero-unit.scss | 16 ++++++++++++++-- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/euth/projects/templates/euth_projects/project_detail.html b/euth/projects/templates/euth_projects/project_detail.html index 38a9a9f2f..b9a2ed0d1 100644 --- a/euth/projects/templates/euth_projects/project_detail.html +++ b/euth/projects/templates/euth_projects/project_detail.html @@ -7,8 +7,14 @@
+
+ {% if view.project.organisation.logo %} + + {% endif %} + {{ view.project.organisation }} +

{{ view.project.name }}

-

{{ view.project.description }}

+

{{ view.project.description | truncatechars:200 }}

{% block phase_cta %}{% endblock %}
diff --git a/euth_wagtail/settings/base.py b/euth_wagtail/settings/base.py index 567a5bbe9..66a3c1ec7 100644 --- a/euth_wagtail/settings/base.py +++ b/euth_wagtail/settings/base.py @@ -190,6 +190,7 @@ 'heroimage': {'size': (1500, 500), 'crop': 'smart'}, 'project_thumbnail': {'size': (800, 400), 'crop': 'smart' }, 'avatar_small': {'size': (31, 31), 'crop': 'smart' }, + 'avatar_medium': {'size': (90, 90), 'crop': 'smart' }, } } # Static files (CSS, JavaScript, Images) diff --git a/euth_wagtail/static/scss/components/_orgs.scss b/euth_wagtail/static/scss/components/_orgs.scss index fc645cbd0..4d6238785 100644 --- a/euth_wagtail/static/scss/components/_orgs.scss +++ b/euth_wagtail/static/scss/components/_orgs.scss @@ -97,3 +97,16 @@ padding: 0; } } + +.org-badge { + font-size: $font-size-medium; + + .org-badge-image { + display: block; + margin: 0 auto; + } + + &, .org-badge-image { + @include rem(margin-bottom, 20px); + } +} diff --git a/euth_wagtail/static/scss/core/_bootstrap-variables.scss b/euth_wagtail/static/scss/core/_bootstrap-variables.scss index d0acc4cce..f05233e57 100644 --- a/euth_wagtail/static/scss/core/_bootstrap-variables.scss +++ b/euth_wagtail/static/scss/core/_bootstrap-variables.scss @@ -66,8 +66,9 @@ $font-family-base: $font-family-sans-serif !default; $font-size-base: 16px !default; $font-size-large: 24px !default; // ~18px -$font-size-xlarge: 30px !default; // ~18px +$font-size-xlarge: 36px !default; // ~18px $font-size-small: 14px !default; // ~12px +$font-size-medium: 18px !default; $font-size-h1: floor(($font-size-base * 2.6)) !default; // ~36px $font-size-h2: floor(($font-size-base * 2.15)) !default; // ~30px diff --git a/euth_wagtail/static/scss/core/_hero-unit.scss b/euth_wagtail/static/scss/core/_hero-unit.scss index 873b905d7..a535fcc22 100644 --- a/euth_wagtail/static/scss/core/_hero-unit.scss +++ b/euth_wagtail/static/scss/core/_hero-unit.scss @@ -29,7 +29,7 @@ } .euth-hero-unit-header { - @include rem(padding-top, 75px); + @include rem(padding-top, 53px); color: #fff; .m-dark-text { @@ -40,6 +40,10 @@ @extend .euth-hero-unit-title; } + p { + @extend .euth-hero-unit-description; + } + .button { @include rem(margin-top, 13px); // background-color: $brand-brand1; @@ -47,5 +51,13 @@ } .euth-hero-unit-title { - @include rem(font-size, 28px); + @include rem(font-size, $font-size-xlarge); + @include rem(margin, 0 0 20px); + letter-spacing: 3px; +} + +.euth-hero-unit-description { + @include rem(padding, 0 70px); + line-height: 1.63; + margin-bottom: 0; } From f21b64b038e4ef9db9cdcf0d1bf989c2a69b5f9a Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Wed, 17 Aug 2016 11:20:21 +0200 Subject: [PATCH 03/29] Make tab panels more like design --- .../euth_projects/project_detail.html | 10 +++++++--- euth_wagtail/static/scss/core/_tabs.scss | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/euth/projects/templates/euth_projects/project_detail.html b/euth/projects/templates/euth_projects/project_detail.html index b9a2ed0d1..7b22d721d 100644 --- a/euth/projects/templates/euth_projects/project_detail.html +++ b/euth/projects/templates/euth_projects/project_detail.html @@ -41,11 +41,15 @@

{{ view.project.name }}

-

{% trans "info" %}

- {{ view.project.description }} +

{% trans "info" %}

+
+ {{ view.project.description }} +
- {% block phase_content %}{% endblock %} +
+ {% block phase_content %}{% endblock %} +
diff --git a/euth_wagtail/static/scss/core/_tabs.scss b/euth_wagtail/static/scss/core/_tabs.scss index 4ea687172..820813174 100644 --- a/euth_wagtail/static/scss/core/_tabs.scss +++ b/euth_wagtail/static/scss/core/_tabs.scss @@ -29,3 +29,22 @@ left: 50%; } } + +.tab-panel { + @include rem(margin, 53px 0 86px); + + > h3, .idea-list > h2, .tab-panel-title { + @include rem(font-size, $font-size-large); + @include rem(margin, 0 0 12px); + text-transform: uppercase; + } + + .tab-panel-description { + @include rem(font-size, $font-size-medium); + line-height: 1.56; + + .idea-list { + padding-top: 0; + } + } +} From 445235c4616b6a5cac9c151d5143762bde371eed Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Wed, 17 Aug 2016 11:41:06 +0200 Subject: [PATCH 04/29] Add badges --- .../templates/euth_projects/project_detail.html | 11 ++++++++++- euth_wagtail/static/scss/all.scss | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/euth/projects/templates/euth_projects/project_detail.html b/euth/projects/templates/euth_projects/project_detail.html index 7b22d721d..3638ab618 100644 --- a/euth/projects/templates/euth_projects/project_detail.html +++ b/euth/projects/templates/euth_projects/project_detail.html @@ -43,7 +43,16 @@

{{ view.project.name }}

{% trans "info" %}

- {{ view.project.description }} + {{ view.project.description }} +
+ + Dummy Dummy + 12 Sep 2016 + + + Dummy Dummy + 12 Sep 2016 +
diff --git a/euth_wagtail/static/scss/all.scss b/euth_wagtail/static/scss/all.scss index 6b640b9f8..a638094b0 100644 --- a/euth_wagtail/static/scss/all.scss +++ b/euth_wagtail/static/scss/all.scss @@ -4,6 +4,8 @@ @import "scss/core/mixins"; @import "scss/core/type"; @import "scss/core/containers"; + +@import "scss/core/badges"; @import "scss/core/buttons"; @import "scss/core/blocks"; @import "scss/core/forms"; From 7da1a2ab6fca43f035a6061192a34e77920c9e04 Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Wed, 17 Aug 2016 11:41:25 +0200 Subject: [PATCH 05/29] Add badge css --- euth_wagtail/static/scss/core/_badges.scss | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 euth_wagtail/static/scss/core/_badges.scss diff --git a/euth_wagtail/static/scss/core/_badges.scss b/euth_wagtail/static/scss/core/_badges.scss new file mode 100644 index 000000000..4cf2f99e5 --- /dev/null +++ b/euth_wagtail/static/scss/core/_badges.scss @@ -0,0 +1,14 @@ +.badge-group { + @include rem(margin-top, 23px); + + .badge { + @include rem(border-radius, 8px); + @include rem(font-size, $font-size-small); + @include rem(margin-right, 5px); + @include rem(padding, 0 14px); + background: #000; + color: #fff; + display: inline-block; + line-height: 35px; + } +} From 44715e4c28ffb06183b14b9216591f90ba25d4dd Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:00:13 +0200 Subject: [PATCH 06/29] add avatar to user model --- .../migrations/0003_user_avatar.py | 20 +++++++++++++++++++ euth/user_management/models.py | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 euth/user_management/migrations/0003_user_avatar.py diff --git a/euth/user_management/migrations/0003_user_avatar.py b/euth/user_management/migrations/0003_user_avatar.py new file mode 100644 index 000000000..81f148718 --- /dev/null +++ b/euth/user_management/migrations/0003_user_avatar.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import euth.contrib.validators + + +class Migration(migrations.Migration): + + dependencies = [ + ('user_management', '0002_auto_20160715_1640'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='avatar', + field=models.ImageField(blank=True, upload_to='user_management/images', validators=[euth.contrib.validators.validate_logo]), + ), + ] diff --git a/euth/user_management/models.py b/euth/user_management/models.py index 7cc38c547..b1c3bb03e 100644 --- a/euth/user_management/models.py +++ b/euth/user_management/models.py @@ -43,6 +43,8 @@ class User(auth_models.AbstractBaseUser, auth_models.PermissionsMixin): is_active = models.BooleanField(_('active'), default=True, help_text=IS_ACTIVE_HELP) date_joined = models.DateTimeField(editable=False, default=timezone.now) + avatar = models.ImageField(upload_to='user_management/images', blank=True, + validators=[euth_validators.validate_logo]) objects = auth_models.UserManager() From 3cc8bea831b3e3e6b4d96cfd5a6c07764b806303 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:01:37 +0200 Subject: [PATCH 07/29] add user update form to dashboard --- .../euth_dashboard/profile_detail.html | 24 ++++++++++++++++++- euth/dashboard/views.py | 16 +++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/euth/dashboard/templates/euth_dashboard/profile_detail.html b/euth/dashboard/templates/euth_dashboard/profile_detail.html index a7777158e..3eacb4116 100644 --- a/euth/dashboard/templates/euth_dashboard/profile_detail.html +++ b/euth/dashboard/templates/euth_dashboard/profile_detail.html @@ -1,6 +1,28 @@ {% extends "euth_dashboard/base_dashboard.html" %} -{% load i18n %} +{% load widget_tweaks i18n %} {% block dashboard_content %}

{% trans 'Profile' %}

+ +
+
+ {% csrf_token %} + {{ form.media }} + {% for field in form %} +
+ + {% render_field field class="form-control" %} + {% if field.errors %} + {{ field.errors.0 }} + {% endif %} +
+ {% endfor %} + + {% if mode == 'create' %} + {% trans 'cancel'%} + {% elif mode == 'update' %} + {% trans 'cancel'%} + {% endif %} +
+
{% endblock %} diff --git a/euth/dashboard/views.py b/euth/dashboard/views.py index 29ac33116..f0bf5cf7e 100644 --- a/euth/dashboard/views.py +++ b/euth/dashboard/views.py @@ -1,11 +1,23 @@ +from braces.views import LoginRequiredMixin +from django.shortcuts import get_object_or_404 from django.views import generic +from euth.user_management import models as user_models -class DashboardProfileView(generic.TemplateView): +class DashboardProfileView(LoginRequiredMixin, generic.UpdateView): + + model = user_models.User template_name = "euth_dashboard/profile_detail.html" + fields = ['avatar', 'email'] + + def get_object(self): + return get_object_or_404(user_models.User, pk=self.request.user.id) + + def get_success_url(self): + return self.request.path -class DashboardOverviewView(generic.TemplateView): +class DashboardOverviewView(LoginRequiredMixin, generic.TemplateView): template_name = "euth_dashboard/dashboard_overview.html" From 8b47c9ca00fdf84facf57c5070fd99d91ac575ac Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:02:14 +0200 Subject: [PATCH 08/29] display user avatar in idea list tile and detail --- euth/ideas/templates/euth_ideas/idea_detail.html | 9 ++++----- .../templates/euth_ideas/includes/idea_list_tile.html | 10 +++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/euth/ideas/templates/euth_ideas/idea_detail.html b/euth/ideas/templates/euth_ideas/idea_detail.html index 9937c72e4..ba8299248 100644 --- a/euth/ideas/templates/euth_ideas/idea_detail.html +++ b/euth/ideas/templates/euth_ideas/idea_detail.html @@ -40,7 +40,11 @@

{{ idea.name }}

+ {% if idea.creator.avatar %} + + {% else %} + {% endif %}
{{ idea.creator.username }}
@@ -51,11 +55,6 @@

{{ idea.name }}

{% react_rates idea %} - -
{% react_comments idea %} diff --git a/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html b/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html index 985237e26..727e22d13 100644 --- a/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html +++ b/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html @@ -17,15 +17,19 @@

- {{ idea.positive_rates }} {{ idea.negative_rates }} {{ idea.comments.count }}
- -
{{ idea.creator.username }} {{ idea.created | date }}
+ {% if idea.creator.avatar %} + + {% else %} + + {% endif %} +
{{ idea.creator.username }} {{ idea.created | date }} +
From 5d363f360b74cd0041af7bab1d9bc44051f90407 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:02:50 +0200 Subject: [PATCH 09/29] add link to dashboard to indicator menu --- .../templates/user_management/indicator_menu.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/euth/user_management/templates/user_management/indicator_menu.html b/euth/user_management/templates/user_management/indicator_menu.html index 152fb4922..3576a4671 100644 --- a/euth/user_management/templates/user_management/indicator_menu.html +++ b/euth/user_management/templates/user_management/indicator_menu.html @@ -10,6 +10,11 @@ Admin {% endif %} + {% if user.is_authenticated %} +
  • + Dashboard +
  • + {% endif %}
  • From 51830296e3cae2c182f627393d6aa41974411609 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:03:46 +0200 Subject: [PATCH 10/29] add signals for update or delete user avatar --- euth/user_management/models.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/euth/user_management/models.py b/euth/user_management/models.py index b1c3bb03e..8538415a8 100644 --- a/euth/user_management/models.py +++ b/euth/user_management/models.py @@ -4,9 +4,14 @@ from django.contrib.auth import models as auth_models from django.core import validators from django.db import models +from django.db.models.signals import post_delete, post_init, post_save +from django.dispatch import receiver from django.utils import timezone from django.utils.translation import ugettext_lazy as _ +from euth.contrib import validators as euth_validators +from euth.contrib import services + USERNAME_INVALID_MESSAGE = _('Enter a valid username. This value may contain ' 'only letters, digits, spaces and @/./+/-/_ ' 'characters. It must start with a digit or a ' @@ -32,12 +37,12 @@ class User(auth_models.AbstractBaseUser, auth_models.PermissionsMixin): validators=[USERNAME_VALIDATOR], error_messages={ 'unique': _(USERNAME_NOT_UNIQUE), - }) + }) email = models.EmailField(_('email address'), unique=True, error_messages={ 'unique': EMAIL_NOT_UNIQUE, - }) + }) is_staff = models.BooleanField(_('staff status'), default=False, help_text=IS_STAFF_HELP) is_active = models.BooleanField(_('active'), default=True, @@ -78,3 +83,20 @@ class Reset(models.Model): on_delete=models.CASCADE ) next_action = models.URLField(blank=True, null=True) + + +@receiver(post_init, sender=User) +def backup_image_path(sender, instance, **kwargs): + instance._current_image_file = instance.avatar + + +@receiver(post_save, sender=User) +def delete_old_image(sender, instance, **kwargs): + if hasattr(instance, '_current_image_file'): + if instance._current_image_file != instance.avatar: + services.delete_images([instance._current_image_file]) + + +@receiver(post_delete, sender=User) +def delete_images_for_User(sender, instance, **kwargs): + services.delete_images([instance.avatar]) From b8a7c8f0f6ba2ed9254d3884dcab490a92072938 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:04:02 +0200 Subject: [PATCH 11/29] add tests to user management --- tests/user_management/test_models.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/user_management/test_models.py diff --git a/tests/user_management/test_models.py b/tests/user_management/test_models.py new file mode 100644 index 000000000..36803ef7d --- /dev/null +++ b/tests/user_management/test_models.py @@ -0,0 +1,32 @@ +import os + +import pytest +from django.conf import settings +from tests import helpers + + +@pytest.mark.django_db +def test_delete_idea(user_factory, ImagePNG): + user = user_factory(avatar=ImagePNG) + image_path = os.path.join(settings.MEDIA_ROOT, user.avatar.path) + + assert os.path.isfile(image_path) + + user.delete() + assert not os.path.isfile(image_path) + + +@pytest.mark.django_db +def test_image_deleted_after_update(user_factory, ImagePNG): + user = user_factory(avatar=ImagePNG) + image_path = os.path.join(settings.MEDIA_ROOT, user.avatar.path) + thumbnail_path = helpers.createThumbnail(user.avatar) + + assert os.path.isfile(image_path) + assert os.path.isfile(thumbnail_path) + + user.avatar = None + user.save() + + assert not os.path.isfile(image_path) + assert not os.path.isfile(thumbnail_path) From 701a5c8ef5c71f7aca860643e1ed7637daff1236 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:04:17 +0200 Subject: [PATCH 12/29] add dashboard tests --- tests/dashboard/__init__.py | 0 tests/dashboard/test_dashboard_views.py | 43 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/dashboard/__init__.py create mode 100644 tests/dashboard/test_dashboard_views.py diff --git a/tests/dashboard/__init__.py b/tests/dashboard/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/dashboard/test_dashboard_views.py b/tests/dashboard/test_dashboard_views.py new file mode 100644 index 000000000..49955187d --- /dev/null +++ b/tests/dashboard/test_dashboard_views.py @@ -0,0 +1,43 @@ +import pytest +from django.core.urlresolvers import reverse + + +@pytest.mark.django_db +def test_anonymous_cannot_view_dashboard_overview(client): + url = reverse('dashboard-overview') + response = client.get(url) + assert response.status_code == 302 + + +@pytest.mark.django_db +def test_anonymous_cannot_view_dashboard_profile(client): + url = reverse('dashboard-profile') + response = client.get(url) + assert response.status_code == 302 + + +@pytest.mark.django_db +def test_authenticated_user_can_view_dashboard(client, user): + url = reverse('dashboard-overview') + login_url = reverse('login') + client.post(login_url, {'email': user.email, 'password': 'password'}) + response = client.get(url) + assert response.status_code == 200 + + +@pytest.mark.django_db +def test_authenticated_user_can_view_profile(client, user): + url = reverse('dashboard-profile') + login_url = reverse('login') + client.post(login_url, {'email': user.email, 'password': 'password'}) + response = client.get(url) + assert response.status_code == 200 + + +@pytest.mark.django_db +def test_authenticated_user_can_upload_avatar(client, user): + url = reverse('dashboard-profile') + login_url = reverse('login') + client.post(login_url, {'email': user.email, 'password': 'password'}) + response = client.get(url) + assert response.status_code == 200 From 359faf4736d15b4929db9bcd1679eb3488ebf3bf Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:35:14 +0200 Subject: [PATCH 13/29] add signal --- euth/comments/signals.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/euth/comments/signals.py b/euth/comments/signals.py index a4ff755b3..d9bd60ad2 100644 --- a/euth/comments/signals.py +++ b/euth/comments/signals.py @@ -8,7 +8,14 @@ @receiver(post_delete, sender=Comment) -def delete_comments_for_Idea(sender, instance, **kwargs): +def delete_comments_for_Comment(sender, instance, **kwargs): contenttype = ContentType.objects.get_for_model(instance) pk = instance.pk services.delete_comments(contenttype, pk) + + +@receiver(post_delete, sender=Comment) +def delete_rates_for_Comment(sender, instance, **kwargs): + contenttype = ContentType.objects.get_for_model(instance) + pk = instance.pk + services.delete_rates(contenttype, pk) From 0080e4e498c55b83d8fa0a0614b5cdf3c500c92f Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:35:32 +0200 Subject: [PATCH 14/29] update tests --- tests/comments/conftest.py | 2 ++ tests/comments/test_model.py | 28 ++++++++++++++++++++++++++++ tests/rates/test_rate_models.py | 1 - 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/comments/test_model.py diff --git a/tests/comments/conftest.py b/tests/comments/conftest.py index dac04feb6..ccf28d60d 100644 --- a/tests/comments/conftest.py +++ b/tests/comments/conftest.py @@ -1,5 +1,7 @@ from pytest_factoryboy import register +from tests.rates import factories as rate_factories import factories +register(rate_factories.RateFactory) register(factories.CommentFactory) diff --git a/tests/comments/test_model.py b/tests/comments/test_model.py new file mode 100644 index 000000000..4b5cb92cc --- /dev/null +++ b/tests/comments/test_model.py @@ -0,0 +1,28 @@ +import pytest +from django.contrib.contenttypes.models import ContentType + +from euth.comments import models as comments_models +from euth.rates import models as rate_models + + +@pytest.mark.django_db +def test_delete_comment(comment_factory, rate_factory): + comment = comment_factory() + contenttype = ContentType.objects.get_for_model(comment) + + for i in range(5): + comment_factory(object_pk=comment.id, content_type=contenttype) + comment_count = comments_models.Comment.objects.all().count() + + rate_factory(object_pk=comment.id, content_type=contenttype) + rate_count = rate_models.Rate.objects.all().count() + + assert comment_count == 6 + assert rate_count == 1 + + comment.delete() + + comment_count = comments_models.Comment.objects.all().count() + rate_count = rate_models.Rate.objects.all().count() + assert comment_count == 0 + assert rate_count == 0 diff --git a/tests/rates/test_rate_models.py b/tests/rates/test_rate_models.py index 2ac439c2b..a1393df6b 100644 --- a/tests/rates/test_rate_models.py +++ b/tests/rates/test_rate_models.py @@ -1,5 +1,4 @@ import pytest - from django.db import IntegrityError From 542e2d905c9ca3ab4e987ab48654606987ae5f25 Mon Sep 17 00:00:00 2001 From: Magdalena Noffke Date: Wed, 17 Aug 2016 13:39:55 +0200 Subject: [PATCH 15/29] fix typo --- euth/comments/static/comments/react_comments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/euth/comments/static/comments/react_comments.js b/euth/comments/static/comments/react_comments.js index 79eaa7438..c69aed5fe 100644 --- a/euth/comments/static/comments/react_comments.js +++ b/euth/comments/static/comments/react_comments.js @@ -539,7 +539,7 @@ var CommentEditForm = React.createClass({ }), h('input.cancel-button', { type: 'submit', - value: django.gettext('cancle'), + value: django.gettext('cancel'), onClick: this.props.handleCancel }) ]) From 12ae402641db80aa4e3568e0d34a1bae65c42610 Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Wed, 17 Aug 2016 17:17:10 +0200 Subject: [PATCH 16/29] Fix up idea list and add creat new proposal button --- .../ideas/templates/euth_ideas/idea_list.html | 5 ++ .../euth_ideas/includes/idea_list_tile.html | 6 +-- .../euth_projects/project_detail.html | 46 +++++++++---------- .../static/scss/components/_avatars.scss | 5 +- .../static/scss/components/_ideas.scss | 43 +++++++++++++---- euth_wagtail/static/scss/core/_tiles.scss | 9 +++- 6 files changed, 72 insertions(+), 42 deletions(-) diff --git a/euth/ideas/templates/euth_ideas/idea_list.html b/euth/ideas/templates/euth_ideas/idea_list.html index 39274d6ab..0ed3ec680 100644 --- a/euth/ideas/templates/euth_ideas/idea_list.html +++ b/euth/ideas/templates/euth_ideas/idea_list.html @@ -10,6 +10,11 @@

    {{ view.phase.name }}

    {{ view.phase.description }}

    + + {% for idea in idea_list %} {% include "euth_ideas/includes/idea_list_tile.html" with idea=idea %} {% endfor %} diff --git a/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html b/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html index 985237e26..15d1e9758 100644 --- a/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html +++ b/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html @@ -1,13 +1,13 @@ {% load i18n thumbnail static %}
    {% if idea.image %} - + {% else %} - + {% endif %} -
    +

    diff --git a/euth/projects/templates/euth_projects/project_detail.html b/euth/projects/templates/euth_projects/project_detail.html index 3638ab618..8d2ee8794 100644 --- a/euth/projects/templates/euth_projects/project_detail.html +++ b/euth/projects/templates/euth_projects/project_detail.html @@ -39,30 +39,28 @@

    {{ view.project.name }}

    -
    -
    -

    {% trans "info" %}

    -
    - {{ view.project.description }} -
    - - Dummy Dummy - 12 Sep 2016 - - - Dummy Dummy - 12 Sep 2016 - -
    -
    -
    -
    - {% block phase_content %}{% endblock %} -
    -
    -
    -
    -
    +
    +

    {% trans "info" %}

    +
    + {{ view.project.description }} +
    + + Dummy Dummy + 12 Sep 2016 + + + Dummy Dummy + 12 Sep 2016 + +
    +
    +
    +
    + {% block phase_content %}{% endblock %} +
    +
    +
    +
    {% if view.project.other_projects %}
    diff --git a/euth_wagtail/static/scss/components/_avatars.scss b/euth_wagtail/static/scss/components/_avatars.scss index 10e2e96e0..7a05f8f80 100644 --- a/euth_wagtail/static/scss/components/_avatars.scss +++ b/euth_wagtail/static/scss/components/_avatars.scss @@ -1,7 +1,6 @@ .avatar-small { - @include rem(font-size, 14px); - @include rem(margin-top, 17px); + @include rem(margin-top, 12px); height: 31px; img{ @@ -19,4 +18,4 @@ text-align: justify; line-height: 31px; } -} \ No newline at end of file +} diff --git a/euth_wagtail/static/scss/components/_ideas.scss b/euth_wagtail/static/scss/components/_ideas.scss index 3222bb880..5f82165c7 100644 --- a/euth_wagtail/static/scss/components/_ideas.scss +++ b/euth_wagtail/static/scss/components/_ideas.scss @@ -125,9 +125,6 @@ .idea-list-tile { @extend .tile-list; - box-shadow: 1px 1px 10px 2px rgba(0, 0, 0, 0.1); - @include rem(margin, 0 10px 10px 0); - @include rem(padding, 24px 30px); .idea-tile-image-link { @extend .tile-image-link; @@ -143,27 +140,25 @@ } .idea-tile-body { + @include rem(margin-left, $tile-list-thumbnail-size); + @include rem(padding, 24px 43px 0 28px); border: none; - @include rem(padding, 0px 20px 0px 0px); h3 { margin: 0; padding: 0; - @include rem(font-size, 24px); + @include rem(font-size, 28px); + line-height: 1.17; a { - font-family: $font-family-sans-serif; - font-weight: bold; - @include rem(line-height, 1.8); - text-align: justify; color: $black; text-decoration: none; - text-transform: none } } .idea-meta { padding-right: 0; + text-align: right; .idea-meta-item { @include rem(margin-right, 15px); @@ -188,3 +183,31 @@ font-weight: normal; } } + +.idea-list-button { + @extend .idea-list-tile; + @include rem(font-size, $font-size-large); + background: transparent; + border: 2px solid $brand-success; + padding: 0; + text-align: center; + text-transform: uppercase; + width: 100%; + + .idea-list-button-icon { + @include rem(height, $tile-list-thumbnail-size); + @include rem(width, $tile-list-thumbnail-size); + background: $brand-success; + color: #fff; + float: left; + height: $tile-list-thumbnail-size; + + &:before { + @include rem(font-size, 50px); + } + } + + &, .idea-list-button-icon:before { + line-height: $tile-list-thumbnail-size; + } +} diff --git a/euth_wagtail/static/scss/core/_tiles.scss b/euth_wagtail/static/scss/core/_tiles.scss index 03fb45a58..510964420 100644 --- a/euth_wagtail/static/scss/core/_tiles.scss +++ b/euth_wagtail/static/scss/core/_tiles.scss @@ -41,18 +41,23 @@ text-align: center; } +$tile-list-thumbnail-size: 120px; + .tile-list { @extend %tile; - @include rem(padding, 14px 18px); + box-shadow: 1px 1px 10px 2px rgba(0, 0, 0, 0.1); margin-right: 0; + min-height: $tile-list-thumbnail-size; position: relative; } .tile-image-link { + @include rem(height, $tile-list-thumbnail-size); + @include rem(width, $tile-list-thumbnail-size); background-repeat: no-repeat; background-position: center center; + background-size: cover; left: 0; position: absolute; top: 0; - height: 100%; } From 68d682a14f546719485c6efb2b68ee593b38187d Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Wed, 17 Aug 2016 17:43:17 +0200 Subject: [PATCH 17/29] fixed mobile responsiveness for ideas list --- .../templates/euth_ideas/includes/idea_list_tile.html | 4 ++-- euth_wagtail/static/scss/components/_ideas.scss | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html b/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html index 15d1e9758..e8abf5a8f 100644 --- a/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html +++ b/euth/ideas/templates/euth_ideas/includes/idea_list_tile.html @@ -9,14 +9,14 @@ {% endif %}
    -
    + -
    +
    {{ idea.positive_rates }} {{ idea.negative_rates }} diff --git a/euth_wagtail/static/scss/components/_ideas.scss b/euth_wagtail/static/scss/components/_ideas.scss index 5f82165c7..6293e6e51 100644 --- a/euth_wagtail/static/scss/components/_ideas.scss +++ b/euth_wagtail/static/scss/components/_ideas.scss @@ -145,11 +145,15 @@ border: none; h3 { + @include rem(font-size, 28px); margin: 0; padding: 0; - @include rem(font-size, 28px); line-height: 1.17; + @media (max-width: $screen-sm-min) { + @include rem(font-size, $font-size-medium); + } + a { color: $black; text-decoration: none; @@ -174,6 +178,11 @@ &:last-child { margin-right: 0; } + + @media (max-width: $screen-sm-min) { + @include rem(font-size, $font-size-small); + @include rem(margin-right, 5px); + } } } From 81cdf76d7c88f87eb70745052f0fac26e4505c5c Mon Sep 17 00:00:00 2001 From: Caroline Clifford Date: Thu, 18 Aug 2016 12:48:23 +0200 Subject: [PATCH 18/29] Clean up orgs tile --- .../includes/organisation_tile.html | 4 ++-- .../euth_organisations/organisation_list.html | 2 +- euth_wagtail/static/scss/components/_orgs.scss | 17 +++++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/euth/organisations/templates/euth_organisations/includes/organisation_tile.html b/euth/organisations/templates/euth_organisations/includes/organisation_tile.html index af8464238..9128d7ce9 100644 --- a/euth/organisations/templates/euth_organisations/includes/organisation_tile.html +++ b/euth/organisations/templates/euth_organisations/includes/organisation_tile.html @@ -2,7 +2,7 @@
    {% if organisation.image %} - + {% else %} {% endif %} @@ -24,7 +24,7 @@

    {{ organisation.name }}

    -

    {{ organisation.description | truncatechars:150 }}

    +

    {{ organisation.description | truncatechars:200 }}

    diff --git a/euth/organisations/templates/euth_organisations/organisation_list.html b/euth/organisations/templates/euth_organisations/organisation_list.html index 6dcd0bc0e..9e77d75ec 100644 --- a/euth/organisations/templates/euth_organisations/organisation_list.html +++ b/euth/organisations/templates/euth_organisations/organisation_list.html @@ -20,7 +20,7 @@

    {% trans 'Organisations' %}

    {% endfor %}
    {% if is_paginated %} -
    +