Skip to content

Commit

Permalink
billing views
Browse files Browse the repository at this point in the history
  • Loading branch information
khodabande committed Feb 29, 2016
1 parent ad29ab1 commit 4249284
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 77 deletions.
11 changes: 4 additions & 7 deletions 2016_template/templates/custom/bank_payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@
{% endnevercache %}

<p class="muted">{{ team.name }}</p>
{% if paid %}
هزینه‌ی شرکت تیم شما پرداخت شده است.
{% else %}
<div class="row">
<form method="post" action="">
{% csrf_token %}
{{ form }}
</form>
<div class="row">
<div class="center-align col m12 s12 l12">
<button type="submit" class="btn waves-effect">
پرداخت
</button>
</div>
</div>
{% endif %}
</form>
</div>
</div>
</div>
</div>
Expand Down
46 changes: 46 additions & 0 deletions 2016_template/templates/custom/bank_payment_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends "base.html" %}
{% load i18n mezzanine_tags %}

{% block meta_title %}{% trans 'Bank payment' %}{% endblock %}
{% block title %}{% trans 'Bank payment' %}{% endblock %}
{% block extra_head %}
<!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">-->
{% endblock %}

{% block main %}
<div class="row">
<div class="col s12 m12 l8 offset-l2">
<div class="card-panel">
{% nevercache %}
{% if messages %}
<div class="messages">
{% for message in messages %}
<div class="alert alert-dismissable alert-{{ message.tags }}" data-alert="alert">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
{% endnevercache %}

<p>
{# todo: translation #}
پرداخت شما با خطای زیر مواجه شده است:
</p>
<p class="muted">{{ team.name }}</p>
<p>
برای دیدن پرداخت‌ها به
<a href="{% url 'payments_list' %}">این صفحه</a>
و برای پرداخت دوباره به
<a href="{% url 'request_payment' %}">این صفحه</a>
بروید.
</p>

<div>{{ error }}</div>

</div>
</div>
</div>
{% endblock %}
35 changes: 35 additions & 0 deletions 2016_template/templates/custom/bank_payment_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base.html" %}
{% load i18n mezzanine_tags %}

{% block meta_title %}{% trans 'Bank payment' %}{% endblock %}
{% block title %}{% trans 'Bank payment' %}{% endblock %}
{% block extra_head %}
<!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">-->
{% endblock %}

{% block main %}
<div class="row">
<div class="col s12 m12 l8 offset-l2">
<div class="card-panel">
{% nevercache %}
{% if messages %}
<div class="messages">
{% for message in messages %}
<div class="alert alert-dismissable alert-{{ message.tags }}" data-alert="alert">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
{% endnevercache %}

<p class="muted">{{ team.name }}</p>

<div>پرداخت شما با موفقیت انجام شد. بعد از ۵ ثانیه به صفحه‌ی تیم خود هدایت خواهید شد.</div>

</div>
</div>
</div>
{% endblock %}
37 changes: 37 additions & 0 deletions 2016_template/templates/custom/bank_payments_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends "base.html" %}
{% load i18n mezzanine_tags %}

{% block meta_title %}{% trans 'Bank payment' %}{% endblock %}
{% block title %}{% trans 'Bank payment' %}{% endblock %}
{% block extra_head %}
<!--<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">-->
{% endblock %}

{% block main %}
<div class="row">
<div class="col s12 m12 l8 offset-l2">
<div class="card-panel">
{% nevercache %}
{% if messages %}
<div class="messages">
{% for message in messages %}
<div class="alert alert-dismissable alert-{{ message.tags }}" data-alert="alert">
<button type="button" class="close" data-dismiss="alert"
aria-hidden="true">&times;</button>
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
{% endnevercache %}

{% for transaction in payments %}
<div>
{{ transaction.created }}, {{ transaction.amount }}, {{ transaction.status }}
</div>
{% endfor %}

</div>
</div>
</div>
{% endblock %}
20 changes: 12 additions & 8 deletions 2016_template/templates/custom/my_team.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,18 @@ <h4>{% trans 'team members' %}</h4>
</button>
</a>
</div>
<div class="centered center-aligned center col s12 m12 l12">
{% if request.team.paid_site_price %}
هزینه‌ی شرکت تیم شما پرداخت شده است
{% else %}
هزینه‌ی شرکت تیم شما در مسابقه پرداخت نشده است. این هزینه برابر ۱۰۰ هزار تومان می‌باشد.<br />
<a href="{% url 'pay_site_price' %}" class="btn btn-primary">پرداخت</a>
{% endif %}
</div>
{% if request.team.should_pay %}
<div class="centered center-aligned center col s12 m12 l12">
{% if request.team.has_paid %}
هزینه‌ی شرکت تیم شما پرداخت شده است
{% else %}
هزینه‌ی شرکت تیم شما در مسابقه پرداخت نشده است. این هزینه برابر
{{ request.team.payment_value }}
ریال می‌باشد.<br />
<a href="{% url 'request_payment' %}" class="btn btn-primary">پرداخت</a>
{% endif %}
</div>
{% endif %}
{% endif %}
</div>
<div class="px-20 vertical spacer"></div>
Expand Down
4 changes: 0 additions & 4 deletions AIC_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,3 @@
},
}
}

BANK_USERNAME = os.environ.get('BANK_USERNAME', '')
BANK_PASSWORD = os.environ.get('BANK_PASSWORD', '')
BANK_GROUP_ID = os.environ.get('BANK_GROUP_ID', '')
4 changes: 3 additions & 1 deletion base/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,14 @@ class TeamAdmin(ImportExportModelAdmin):
resource_class = TeamResource
search_fields = ('name',)
list_filter = ('final', 'show', 'will_come', 'head__country', 'final_submission')
list_display = ('name', 'competition', 'head', 'countries', 'show', 'final', 'is_last_submit_final', 'site_participation_possible')
list_display = ('name', 'competition', 'head', 'countries', 'show', 'final', 'is_last_submit_final', 'site_participation_possible', 'should_pay', 'payment_value')
fields = (
('name', 'head', 'show'),
('competition', 'final'),
('will_come','site_participation_possible'),
('final_submission',),
('should_pay',),
('payment_value',),
)
inlines = [MembersInline]

Expand Down
28 changes: 28 additions & 0 deletions base/migrations/0041_auto_20160229_2341.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('base', '0040_auto_20160229_1136'),
]

operations = [
migrations.RemoveField(
model_name='team',
name='paid',
),
migrations.AddField(
model_name='team',
name='payment_value',
field=models.PositiveIntegerField(default=0, verbose_name='Payment value'),
),
migrations.AddField(
model_name='team',
name='should_pay',
field=models.BooleanField(default=False, verbose_name='Should pay?'),
),
]
19 changes: 19 additions & 0 deletions base/migrations/0042_auto_20160229_2349.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('base', '0041_auto_20160229_2341'),
]

operations = [
migrations.AlterField(
model_name='team',
name='payment_value',
field=models.PositiveIntegerField(default=0, verbose_name='Payment value (rials)'),
),
]
7 changes: 6 additions & 1 deletion base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class Team(models.Model):

will_come = models.PositiveSmallIntegerField(verbose_name=_("will come to site"), choices=WILL_COME_CHOICES,
default=2)
paid = models.BooleanField(default=False)
should_pay = models.BooleanField(verbose_name=_("Should pay?"), default=False)
payment_value = models.PositiveIntegerField(verbose_name=_("Payment value (rials)"), default=0)

def __unicode__(self):
return 'Team%d(%s)' % (self.id, self.name)
Expand All @@ -59,6 +60,10 @@ class Meta:
verbose_name = _('team')
verbose_name_plural = _('teams')

@property
def has_paid(self):
return self.transactions.filter(status='v').exists()

def get_members(self):
return self.member_set.exclude(pk=self.head.pk).distinct()

Expand Down
3 changes: 2 additions & 1 deletion base/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from django.conf.urls import patterns, url
from django.conf.urls import patterns, url, include

urlpatterns = patterns(
'base.views',
Expand All @@ -23,4 +23,5 @@
url("^final_submission", 'final_submission', name='set_final_submission'),
url("^play/$", 'play_log', name='play_log'),
url("^scoreboard$", 'scoreboard', name="scoreboard"),
url("^billing/", include('billing.urls')),
)
7 changes: 4 additions & 3 deletions billing/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from .models import Transaction


@admin.register(Transaction)
class TransactionAdmin(admin.ModelAdmin):
readonly_fields = ['user', 'amount', 'status', 'our_id', 'order_id', 'bank', 'reference_id', 'created', 'updated']
list_display = ['user', 'amount', 'status', 'bank', 'reference_id', 'updated']
readonly_fields = ['team', 'amount', 'status', 'order_id', 'bank', 'reference_id', 'created', 'updated']
list_display = ['team', 'amount', 'status', 'bank', 'reference_id', 'updated']

admin.site.register(Transaction, TransactionAdmin)
2 changes: 1 addition & 1 deletion billing/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class UserCompletionForm(forms.ModelForm):

class Meta:
model = Member
fields = ('phone_number', 'mobile_number', 'national_code')
fields = ('phone_number', 'mobile_number', 'national_code')
24 changes: 24 additions & 0 deletions billing/migrations/0002_auto_20160229_2341.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('base', '0041_auto_20160229_2341'),
('billing', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='transaction',
name='user',
),
migrations.AddField(
model_name='transaction',
name='team',
field=models.ForeignKey(related_name='transactions', to='base.Team', null=True),
),
]
18 changes: 18 additions & 0 deletions billing/migrations/0003_remove_transaction_our_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('billing', '0002_auto_20160229_2341'),
]

operations = [
migrations.RemoveField(
model_name='transaction',
name='our_id',
),
]
19 changes: 19 additions & 0 deletions billing/migrations/0004_transaction_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('billing', '0003_remove_transaction_our_id'),
]

operations = [
migrations.AddField(
model_name='transaction',
name='error',
field=models.CharField(max_length=100, null=True, blank=True),
),
]
Loading

0 comments on commit 4249284

Please sign in to comment.