Skip to content

Commit

Permalink
prepares scaffolding for #151 and #104
Browse files Browse the repository at this point in the history
  • Loading branch information
smirolo committed Sep 3, 2019
1 parent 6da74ab commit 972b56e
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 19 deletions.
23 changes: 23 additions & 0 deletions djaoapp/management/commands/load_test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.db.utils import IntegrityError
from django.template.defaultfilters import slugify
from django.utils.timezone import utc
from faker import Faker
from multitier.thread_locals import set_current_site
from multitier.utils import get_site_model
from saas.models import (Charge, ChargeItem, Coupon, Organization, Plan,
Expand Down Expand Up @@ -206,6 +207,9 @@ def _handle(self, *args, **options):
processor = Organization.objects.get(pk=PROCESSOR_ID)
self.generate_coupons(provider)
self.generate_transactions(provider, processor, from_date, now)
subscriber = Organization.objects.filter(slug='stephanie').first()
if subscriber:
self.generate_subscriptions(subscriber)

def generate_coupons(self, provider, nb_coupons=None):
if nb_coupons is None:
Expand All @@ -219,6 +223,25 @@ def generate_coupons(self, provider, nb_coupons=None):
Coupon.objects.create(code=coupon_code, percent=coupon_percent,
organization=provider)

def generate_subscriptions(self, subscriber, nb_subscriptions=None):
at_time = datetime_or_now()
if nb_subscriptions is None:
nb_subscriptions = settings.REST_FRAMEWORK['PAGE_SIZE'] * 4
self.stdout.write("%d subscriptions\n" % nb_subscriptions)
nb_plans = Plan.objects.count()
fake = Faker()
for _ in range(0, nb_subscriptions):
rank = random.randint(1, nb_plans - 1)
plan = Plan.objects.all().order_by('pk')[rank]
created_at = fake.date_time_between_dates(
datetime_start=at_time - datetime.timedelta(365),
datetime_end=at_time + datetime.timedelta(365))
Subscription.objects.create(
organization=subscriber,
plan=plan,
created_at=created_at,
ends_at=created_at + datetime.timedelta(30))

def generate_transactions(self, provider, processor, from_date, ends_at):
"""
Create Income transactions that represents a growing bussiness.
Expand Down
8 changes: 5 additions & 3 deletions djaoapp/templates/saas/_filter.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="col-md-4">
<div class="col-sm-3">
<uiv-dropdown append-to-body class="w-100 pb-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
Expand All @@ -24,7 +24,7 @@
</uiv-dropdown>
</div>

<div class="col-md-4">
<div class="col-sm-3">
<uiv-dropdown append-to-body class="w-100 pb-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
Expand All @@ -49,6 +49,8 @@
</uiv-dropdown>
</div>

<div class="col">
<div class="col-sm-3">
<div class="pb-3">
{% include "saas/_filter_match.html" %}
</div>
</div>
17 changes: 17 additions & 0 deletions djaoapp/templates/saas/billing/coupons.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@
</div>
<hr />
<div class="row my-3">
<div class="col">
<div class="pb-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">{% trans %}By{% endtrans %}</span>
</div>
<select id="order-by" class="form-control">
<option value="code">{% trans %}code (ascending){% endtrans %}</option>
<option value="percent">{% trans %}discount (highest){% endtrans %}</option>
<option value="ends_at">{% trans %}expiration (soonest){% endtrans %}</option>
<option value="-code">{% trans %}code (descending){% endtrans %}</option>
<option value="-percent">{% trans %}discount (lowest){% endtrans %}</option>
<option value="-ends_at">{% trans %}expiration (latest){% endtrans %}</option>
</select>
</div>
</div>
</div>
{% include "saas/_filter.html" %}
</div>
<div class="text-center" v-show="!itemsLoaded">
Expand Down
2 changes: 0 additions & 2 deletions djaoapp/templates/saas/metrics/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ <h3 class="text-center">
[[humanizeCell(col[1], currentTableData.unit, currentTableData.scale)]]
</td>
</tr>
{% block metrics_extra_data %}
{% endblock %}
</table>
{% block metrics_extra_data %}
{% endblock %}
Expand Down
8 changes: 1 addition & 7 deletions djaoapp/templates/saas/profile/roles/role.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@
</div>
<div class="row">
<div class="col-12">
<div class="input-group input-group-sm mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="search-inp">{% trans %}Filter{% endtrans %}</span>
</div>
<input class="form-control" type="text" id="search-inp"
v-model="params.q" @input="filterList" />
</div>
{% include "saas/_filter_match.html" %}
</div>
</div>
<div class="row">
Expand Down
4 changes: 2 additions & 2 deletions djaoapp/templates/saas/profile/subscribers.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div id="registered-tab-container">
<div class="mt-2">
<div class="form-group d-inline-block">
<input class="form-control" type="text" placeholder="{% trans %}Filter{% endtrans %}" v-model="params.q" @input="filterList"></input>
<input class="form-control" type="text" placeholder="{% trans %}Match{% endtrans %}" v-model="params.q" @input="filterList"></input>
</div>
<div class="pull-right d-inline-block">
<a id="download-registered"
Expand Down Expand Up @@ -87,7 +87,7 @@ <h3 class="text-center"><i class="fa fa-refresh fa-spin fa-2x"></i></h3>
<div class="mt-2">
<div class="form-group d-inline-block">
<input class="form-control d-inline-block"
type="text" placeholder="{% trans %}Filter{% endtrans %}"
type="text" placeholder="{% trans %}Match{% endtrans %}"
v-model="params.q" @input="filterList"></input>
</div>
<div class="pull-right d-inline-block">
Expand Down
5 changes: 3 additions & 2 deletions requirements-legacy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ django-debug-toolbar==1.11 # XXX does not support Django 2.2

# development
drf-yasg==1.8.0
pyYAML==5.1.2
Faker==2.0.0
flex==6.14.0
pygments==2.2.0
swagger-spec-validator==2.3.0
pyYAML==5.1.2
Sphinx==1.7.5
sphinxcontrib-httpdomain==1.6.1
swagger-spec-validator==2.3.0
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ django-debug-toolbar==1.11 # XXX does not support Django 2.2

# development
drf-yasg==1.8.0
pyYAML==5.1.2
Faker==2.0.0
flex==6.14.0
pygments==2.2.0
swagger-spec-validator==2.3.0
pyYAML==5.1.2
Sphinx==1.7.5
sphinxcontrib-httpdomain==1.6.1

swagger-spec-validator==2.3.0

0 comments on commit 972b56e

Please sign in to comment.