-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add created_at field for invites #392; add comments stats page for e…
- Loading branch information
1 parent
caf1db6
commit 8901b34
Showing
14 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
'exporting', | ||
'tasks', | ||
'homepage', | ||
'stats', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 2.1.7 on 2019-05-04 14:11 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('events', '0003_auto_20190417_1852'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='invite', | ||
name='created_at', | ||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Created at'), | ||
preserve_default=False, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class StatsConfig(AppConfig): | ||
name = 'stats' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends 'accounts/base.html' %} | ||
|
||
{% load static %} | ||
|
||
{% block title %} Event Stats {% endblock %} | ||
{% block head %} | ||
<style type="text/css"> | ||
.title{ | ||
text-align: center; | ||
} | ||
</style> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h1 class="title"> Event Stats </h1> | ||
|
||
{% if comments_chart %} | ||
<div style="width:600;height:500"> | ||
{{ comments_chart|safe }} | ||
</div> | ||
{% endif %} | ||
|
||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from . import views | ||
|
||
from django.conf.urls import url | ||
from django.contrib.auth import views as auth_views | ||
from django.urls import path | ||
|
||
|
||
urlpatterns = [ | ||
path('<slug:slug>/statistics', views.get_statistics, name='events.statistics'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from django.shortcuts import render | ||
|
||
from events.models import Comment | ||
from events.models import Event | ||
|
||
import plotly.offline as opy | ||
import plotly.graph_objs as go | ||
|
||
import datetime | ||
|
||
|
||
def get_statistics(request, slug): | ||
|
||
event = Event.objects.get(slug=slug) | ||
members = event.team_members.all() | ||
|
||
if request.user in members: | ||
event_comments = Comment.objects.filter(event=event) | ||
yesterday = datetime.date.today() - datetime.timedelta(days=1) | ||
alltime_comments = event_comments.count() | ||
daily_comments = event_comments.filter(created_at__gt=yesterday).count() | ||
|
||
data = [go.Bar( | ||
x=['Total', 'Daily'], | ||
y=[alltime_comments, daily_comments], | ||
marker=dict( | ||
color=['rgba(50,171,96,1.0)', 'rgba(222,45,38,0.8)'], | ||
line=dict( | ||
color='rgb(8,48,107)', | ||
width=1.5 | ||
), | ||
), | ||
textposition = 'auto', | ||
opacity=0.8, | ||
)] | ||
|
||
layout=go.Layout(title="Comments compare",font=dict(family='Courier New, monospace', size=20, color='#7f7f7f')) | ||
figure=go.Figure(data=data,layout=layout) | ||
comments_chart = opy.plot(figure, auto_open=False, output_type='div') | ||
|
||
context = { | ||
'comments_chart': comments_chart, | ||
} | ||
return render(request, 'event_stats.html', context) | ||
else: | ||
error_message = "Stats are available only\ | ||
to team members." | ||
context = { | ||
'error_message': error_message} | ||
return render(request, 'CRUDops/error.html', context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters