-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
474 additions
and
9 deletions.
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
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,9 @@ | ||
{% extends "admin/index.html" %} | ||
{% load i18n %} | ||
|
||
{% block content %} | ||
<div class="module"> | ||
<a href="/admin/statistics">Statistiques</a> | ||
</div> | ||
{{ block.super }} | ||
{% 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,170 @@ | ||
{% extends "billjobs/base.html" %} | ||
{% block body %} | ||
<section class="section"> | ||
<div class="container"> | ||
<a href="{% url 'admin:index' %}">Accueil</a> | ||
<h2 class="title is-3">Statistiques</h2> | ||
</div> | ||
</section> | ||
|
||
<section class="section"> | ||
<div class="container"> | ||
<div class="columns"> | ||
|
||
|
||
<div class="column"> | ||
<p class="title is-4">Chiffre d'affaire {{ current_month_name | title}} {{ current_year }}</p> | ||
<p class="subtitle is-4" style="background-color: hsla(204, 86%, 53%, 0.25); line-height: 200px; height: 200px; width: 200px; border-radius: 100%; text-align: center; border: 3px dotted black">{{ current_month_revenue}} €</p> | ||
</div> | ||
<div class="column"> | ||
<p class="title is-4">Chiffre d'affaire {{ previous_month_name | title}} {{ current_year }}</p> | ||
<p class="subtitle is-4" style="background-color: hsla(204, 86%, 53%, 0.5); line-height: 200px; height: 200px; width: 200px; border-radius: 100%; text-align: center; border: 3px solid black">{{ previous_month_revenue}} €</p> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
<section class="section"> | ||
<div class="container"> | ||
<table class="table is-striped is-fullwidth"> | ||
<tr> | ||
<th class="is-info">Chiffre d'affaire {{ current_month_name }} {{ current_year }}</th> | ||
<th class="is-info">Chiffre d'affaire {{ previous_month_name }} {{ current_year }}</th> | ||
</tr> | ||
<tr> | ||
<td>{{ current_month_revenue}} €</td> | ||
<td>{{ previous_month_revenue}} €</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</section> | ||
|
||
<section class="section"> | ||
<div class="container"> | ||
|
||
<table class="table is-striped is-fullwidth"> | ||
<p class="title is-4">Chiffre d'affaire annuel</p> | ||
|
||
<tr> | ||
<th class="is-info">Année</th> | ||
{% for month in get_month %} | ||
<th class="is-info">{{ month | title}}</th> | ||
{% endfor %} | ||
<th class="is-danger">Total</th> | ||
</tr> | ||
<tr> | ||
<td>{{ current_year}}</td> | ||
{% for revenue in current_monthly_revenue %} | ||
<td>{{revenue}}</td> | ||
{% endfor %} | ||
<td>{{ current_year_revenue }}<span class="icon has-text-info" | ||
style="border: 1px solid hsl(204, 86%, 53%); border-radius: 100%; cursor: pointer" | ||
title="Estimation du CA annuel : somme des mois finis divisée | ||
par le nombre de mois multipliés par 12."> | ||
i | ||
</span></td> | ||
</tr> | ||
<tr> | ||
<td>{{ previous_year }}</td> | ||
{% for revenue in previous_monthly_revenue %} | ||
<td>{{revenue}}</td> | ||
{% endfor %} | ||
<td>{{ previous_year_revenue }}</td> | ||
</tr> | ||
|
||
</table> | ||
</div> | ||
</section> | ||
|
||
<section class="section"> | ||
<div class="container"> | ||
|
||
</table> | ||
|
||
|
||
<table class="table is-striped is-fullwidth"> | ||
<p class="title is-4">Abonnements / Services {{ current_year }}</p> | ||
|
||
<tr> | ||
<th class="is-info"></th> | ||
{% for month in get_month %} | ||
<th class="is-info">{{ month | title}}</th> | ||
{% endfor %} | ||
<th class="is-danger">Total</th> | ||
</tr> | ||
<tr> | ||
<td>Full Time</td> | ||
{% for subscriptions in current_monthly_subscriptions_1 %} | ||
<td>{{subscriptions}}</td> | ||
{% endfor %} | ||
<td>{{ current_year_subscriptions_1 }}</td> | ||
</tr> | ||
<tr> | ||
<td>Mid Time</td> | ||
{% for subscriptions in current_monthly_subscriptions_2 %} | ||
<td>{{subscriptions}}</td> | ||
{% endfor %} | ||
<td>{{ current_year_subscriptions_2 }}</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Meeting 1 day</td> | ||
{% for subscriptions in current_monthly_subscriptions_3 %} | ||
<td>{{subscriptions}}</td> | ||
{% endfor %} | ||
<td>{{ current_year_subscriptions_3 }}</td> | ||
</tr> | ||
|
||
|
||
</table> | ||
|
||
|
||
|
||
</div> | ||
</section> | ||
|
||
|
||
<section class="section"> | ||
<div class="container"> | ||
|
||
</table> | ||
<table class="table is-striped is-fullwidth"> | ||
<p class="title is-4">Abonnements / Services {{ previous_year}}</p> | ||
|
||
<tr> | ||
<th class="is-info"></th> | ||
{% for month in get_month %} | ||
<th class="is-info">{{ month | title}}</th> | ||
{% endfor %} | ||
<th class="is-danger">Total</th> | ||
</tr> | ||
<tr> | ||
<td>Full Time</td> | ||
{% for subscriptions in previous_monthly_subscriptions_1 %} | ||
<td>{{subscriptions}}</td> | ||
{% endfor %} | ||
<td>{{ previous_year_subscriptions_1 }}</td> | ||
</tr> | ||
<tr> | ||
<td>Mid Time</td> | ||
{% for subscriptions in previous_monthly_subscriptions_2 %} | ||
<td>{{subscriptions}}</td> | ||
{% endfor %} | ||
<td>{{ previous_year_subscriptions_2 }}</td> | ||
</tr> | ||
|
||
<tr> | ||
<td>Meeting 1 day</td> | ||
{% for subscriptions in previous_monthly_subscriptions_3 %} | ||
<td>{{subscriptions}}</td> | ||
{% endfor %} | ||
<td>{{ previous_year_subscriptions_3 }}</td> | ||
</tr> | ||
|
||
</table> | ||
|
||
|
||
|
||
</div> | ||
</section> | ||
|
||
{% endblock body %} |
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,56 @@ | ||
import factory | ||
import factory.fuzzy | ||
import factory.django | ||
from django.contrib.auth.models import User | ||
from django.db.models.signals import post_save | ||
|
||
|
||
@factory.django.mute_signals(post_save) | ||
class UserProfileFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = 'billjobs.UserProfile' | ||
|
||
billing_address = factory.Faker('address') | ||
user = factory.SubFactory( | ||
'billjobs.tests.factories.UserFactory', profile=None) | ||
|
||
|
||
@factory.django.mute_signals(post_save) | ||
class UserFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = User | ||
django_get_or_create = ('username',) | ||
|
||
username = 'steve' | ||
password = 'gates' | ||
first_name = 'Steve' | ||
last_name = 'Gates' | ||
email = 'steve.gates@billjobs.org' | ||
userprofile = factory.RelatedFactory(UserProfileFactory, 'user') | ||
|
||
|
||
class SuperUserFactory(UserFactory): | ||
username = 'bill' | ||
password = 'jobs' | ||
first_name = 'Bill' | ||
last_name = 'Jobs' | ||
email = 'bill.jobs@billjobs.org' | ||
is_staff = True | ||
is_superuser = True | ||
|
||
|
||
class ServiceFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = 'billjobs.Service' | ||
|
||
reference = factory.Sequence(lambda n: 'SE%03d' % n) | ||
price = factory.fuzzy.FuzzyInteger(100, 200, 10) | ||
|
||
|
||
class BillFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = 'billjobs.Bill' | ||
django_get_or_create = ('user',) | ||
|
||
user = factory.SubFactory(UserFactory) | ||
amount = factory.fuzzy.FuzzyInteger(100, 200, 10) |
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,27 @@ | ||
from django.test import TestCase | ||
from django.shortcuts import reverse | ||
from billjobs.tests.factories import UserFactory, SuperUserFactory, BillFactory | ||
|
||
|
||
class Statistics(TestCase): | ||
'''Tests statistics display page''' | ||
|
||
def setUp(self): | ||
self.admin = SuperUserFactory() | ||
self.user = UserFactory() | ||
self.bill = BillFactory.create(user=self.user) | ||
self.bill.billing_date = '2018-01-01' | ||
self.bill.save() | ||
|
||
def test_login_required(self): | ||
'''Test redirect to admin login page''' | ||
response = self.client.get('/admin/statistics', follow=True) | ||
self.assertRedirects( | ||
response, '/admin/login/?next=/admin/statistics') | ||
|
||
def test_admin_access_stats(self): | ||
'''Test an authenticated admin can view statistic page''' | ||
self.client.force_login(self.admin) | ||
response = self.client.get( | ||
'/admin/statistics', follow=False) | ||
self.assertEqual(response.status_code, 200) |
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
from django.conf.urls import url | ||
from . import views | ||
|
||
|
||
from .admin import admin_site | ||
|
||
urlpatterns = [ | ||
url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, | ||
name='generate-pdf'), | ||
url(r'^signup/$', views.signup, name='billjobs_signup'), | ||
url(r'^signup-success/$', views.signup_success, | ||
name='billjobs_signup_success') | ||
name='billjobs_signup_success'), | ||
] |
Oops, something went wrong.