From 2d0e0381d3e4d1c4186c6d75e9b1a003d4febb42 Mon Sep 17 00:00:00 2001 From: Zambom Date: Fri, 3 Feb 2017 21:27:00 -0200 Subject: [PATCH] Adding general mural page --- amadeus/static/css/base/amadeus.css | 20 ++++++++++++++++++++ amadeus/static/css/base/amadeus_responsive.css | 39 +++++++++++++++++++++++++++++++++++++++ amadeus/static/css/themes/green.css | 8 ++++++++ amadeus/templates/base.html | 12 ++++++++---- amadeus/urls.py | 1 + mural/migrations/0002_muralvisualizations.py | 28 ++++++++++++++++++++++++++++ mural/models.py | 8 +++++++- mural/templates/mural/list.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ mural/urls.py | 6 ++++++ mural/views.py | 42 ++++++++++++++++++++++++++++++++++++++++-- requirements.txt | 4 +++- 11 files changed, 207 insertions(+), 8 deletions(-) create mode 100644 mural/migrations/0002_muralvisualizations.py create mode 100644 mural/templates/mural/list.html diff --git a/amadeus/static/css/base/amadeus.css b/amadeus/static/css/base/amadeus.css index 3bb6c63..9686464 100755 --- a/amadeus/static/css/base/amadeus.css +++ b/amadeus/static/css/base/amadeus.css @@ -925,4 +925,24 @@ li.item .notify_badge { padding-right: 0px; font-size: 16px !important; margin: 7px 0 0 0 !important; +} + +.mural .post_make { + padding: 10px; + margin-bottom: 10px; +} +.mural .post_make .user-img { + padding: 0; +} +.mural .post_make .post-field { + padding-right: 0px; +} +.mural .post_make .post-field div { + border-width: 1px; + border-style: solid; + padding: 0px 5px; +} +.mural .post_make .post-field h4 { + cursor: text; + font-style: italic; } \ No newline at end of file diff --git a/amadeus/static/css/base/amadeus_responsive.css b/amadeus/static/css/base/amadeus_responsive.css index b9c5091..1dcbd8b 100644 --- a/amadeus/static/css/base/amadeus_responsive.css +++ b/amadeus/static/css/base/amadeus_responsive.css @@ -1,7 +1,27 @@ +@media(min-width: 1200px) { + .mural .post_make .user-img img { + max-width: 70px; + max-height: 70px; + } + + .mural .post_make .post-field h4 { + line-height: 2.6em; + } +} + @media(max-width: 1199px) { .navbar .navbar-brand { padding: 15px; } + + .mural .post_make .user-img img { + max-width: 65px; + max-height: 65px; + } + + .mural .post_make .post-field h4 { + line-height: 2.3em; + } } @media(max-width: 768px) { @@ -42,6 +62,14 @@ display:none; } + .mural .post_make .user-img img { + max-width: 60px; + max-height: 60px; + } + + .mural .post_make .post-field h4 { + line-height: 2em; + } } @media(min-width: 768px) { @@ -82,3 +110,14 @@ margin-top: 6px; } } + +@media(max-width: 680px) { + .mural .post_make .user-img img { + max-width: 50px; + max-height: 50px; + } + + .mural .post_make .post-field h4 { + line-height: 1.6em; + } +} \ No newline at end of file diff --git a/amadeus/static/css/themes/green.css b/amadeus/static/css/themes/green.css index ac3d50d..a20bce4 100644 --- a/amadeus/static/css/themes/green.css +++ b/amadeus/static/css/themes/green.css @@ -488,6 +488,14 @@ a.add-row { color: #333; } +.mural .post_make { + background: #FFFFFF; +} + +.mural .post_make .post-field div { + border-color: #CCCCCC; +} + @media(max-width: 768px) { .navbar .navbar-nav .dropdown .dropdown-menu li > a { color: #333333 !important; diff --git a/amadeus/templates/base.html b/amadeus/templates/base.html index 1d462dc..adb84e2 100644 --- a/amadeus/templates/base.html +++ b/amadeus/templates/base.html @@ -179,8 +179,10 @@ -
  • - +
  • + + +
  • @@ -228,8 +230,10 @@
  • -
  • - +
  • +
  • diff --git a/amadeus/urls.py b/amadeus/urls.py index 1e817ba..2b52fd2 100644 --- a/amadeus/urls.py +++ b/amadeus/urls.py @@ -29,6 +29,7 @@ urlpatterns = [ url(r'^subjects/', include('subjects.urls', namespace = 'subjects')), url(r'^groups/', include('students_group.urls', namespace = 'groups')), url(r'^topics/', include('topics.urls', namespace = 'topics')), + url(r'^mural/', include('mural.urls', namespace = 'mural')), url(r'^webpages/', include('webpage.urls', namespace = 'webpages')), url(r'^ytvideo/', include('youtube_video.urls', namespace = 'youtube')), url(r'^file_links/', include('file_link.urls', namespace = 'file_links')), diff --git a/mural/migrations/0002_muralvisualizations.py b/mural/migrations/0002_muralvisualizations.py new file mode 100644 index 0000000..cc90bf1 --- /dev/null +++ b/mural/migrations/0002_muralvisualizations.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2017-02-03 21:56 +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 = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('mural', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='MuralVisualizations', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('viewed', models.BooleanField(default=False, verbose_name='Viewed')), + ('comment', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='visualization_comment', to='mural.Comment', verbose_name='Comment')), + ('post', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='visualization_post', to='mural.Mural', verbose_name='Post')), + ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='visualization_user', to=settings.AUTH_USER_MODEL, verbose_name='User')), + ], + ), + ] diff --git a/mural/models.py b/mural/models.py index c522159..716a77d 100644 --- a/mural/models.py +++ b/mural/models.py @@ -39,4 +39,10 @@ class Comment(models.Model): post = models.ForeignKey(Mural, verbose_name = _('Post'), related_name = 'comment_post') user = models.ForeignKey(User, verbose_name = _('User'), related_name = "comment_user", null = True) create_date = models.DateTimeField(_('Create Date'), auto_now_add = True) - last_update = models.DateTimeField(_('Last Update'), auto_now = True) \ No newline at end of file + last_update = models.DateTimeField(_('Last Update'), auto_now = True) + +class MuralVisualizations(models.Model): + viewed = models.BooleanField(_('Viewed'), default = False) + post = models.ForeignKey(Mural, verbose_name = _('Post'), related_name = 'visualization_post', null = True) + comment = models.ForeignKey(Comment, verbose_name = _('Comment'), related_name = 'visualization_comment', null = True) + user = models.ForeignKey(User, verbose_name = _('User'), related_name = "visualization_user", null = True) \ No newline at end of file diff --git a/mural/templates/mural/list.html b/mural/templates/mural/list.html new file mode 100644 index 0000000..138917b --- /dev/null +++ b/mural/templates/mural/list.html @@ -0,0 +1,47 @@ +{% extends 'base.html' %} + +{% load static i18n pagination %} +{% load django_bootstrap_breadcrumbs %} + +{% block breadcrumbs %} + {{ block.super }} + + {% trans 'Mural: General' as general %} + + {% breadcrumb general 'mural:manage_general' %} +{% endblock %} + +{% block content %} + + +
    +
    +
    +
    + +
    +
    +
    +

    {% trans 'Wish to make a new post?' %}

    +
    +
    +
    + + {% if posts.count > 0 %} + {% else %} +
    + +

    {% trans 'There are no posts in this mural yet.' %}

    +
    + {% endif %} +
    +
    +
    +
    +{% endblock %} \ No newline at end of file diff --git a/mural/urls.py b/mural/urls.py index e69de29..b5368e1 100644 --- a/mural/urls.py +++ b/mural/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$', views.GeneralIndex.as_view(), name='manage_general'), +] \ No newline at end of file diff --git a/mural/views.py b/mural/views.py index 91ea44a..c77e74f 100644 --- a/mural/views.py +++ b/mural/views.py @@ -1,3 +1,41 @@ -from django.shortcuts import render +from django.shortcuts import get_object_or_404, redirect, render +from django.views import generic +from django.contrib import messages +from django.http import JsonResponse +from django.core.urlresolvers import reverse, reverse_lazy +from django.utils.translation import ugettext_lazy as _ +from django.contrib.auth.mixins import LoginRequiredMixin +from django.db.models import Q, Count -# Create your views here. +from .models import GeneralPost, CategoryPost, SubjectPost, MuralVisualizations + +class GeneralIndex(LoginRequiredMixin, generic.ListView): + login_url = reverse_lazy("users:login") + redirect_field_name = 'next' + + template_name = 'mural/list.html' + model = GeneralPost + context_object_name = "posts" + paginate_by = 10 + + totals = {} + + def get_queryset(self): + user = self.request.user + + general = GeneralPost.objects.all() + + self.totals['general'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__generalpost__isnull = False) | Q(comment__post__generalpost__isnull = False))).distinct().count() + self.totals['category'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__categorypost__space__coordinators = user) | Q(comment__post__categorypost__space__coordinators = user) | Q(post__categorypost__space__subject_category__professor = user) | Q(post__categorypost__space__subject_category__students = user) | Q(comment__post__categorypost__space__subject_category__professor = user) | Q(comment__post__categorypost__space__subject_category__students = user))).distinct().count() + self.totals['subject'] = MuralVisualizations.objects.filter(Q(user = user) & Q(viewed = False) & (Q(post__subjectpost__space__professor = user) | Q(comment__post__subjectpost__space__professor = user) | Q(post__subjectpost__space__students = user) | Q(comment__post__subjectpost__space__students = user))).distinct().count() + + return general + + def get_context_data(self, **kwargs): + context = super(GeneralIndex, self).get_context_data(**kwargs) + + context['title'] = _('Mural') + context['totals'] = self.totals + context['mural_menu_active'] = 'subjects_menu_active' + + return context diff --git a/requirements.txt b/requirements.txt index ada73ea..89ed650 100644 --- a/requirements.txt +++ b/requirements.txt @@ -35,4 +35,6 @@ whitenoise==3.2.2 django-session-security==2.4.0 django-cron==0.5.0 django-crontab==0.7.1 -python-dateutil==2.6.0 \ No newline at end of file +python-dateutil==2.6.0 +channels==1.0.3 +asgi_redis==1.0.0 \ No newline at end of file -- libgit2 0.21.2