forked from GithubBackups/healthchecks
Add Profile.bill_to field which goes on invoices.
This commit is contained in:
parent
74f7c50a65
commit
dc76e4bdde
@ -26,7 +26,7 @@ class ProfileFieldset(Fieldset):
|
||||
class TeamFieldset(Fieldset):
|
||||
name = "Team"
|
||||
fields = ("team_name", "team_access_allowed", "check_limit",
|
||||
"ping_log_limit")
|
||||
"ping_log_limit", "bill_to")
|
||||
|
||||
|
||||
@admin.register(Profile)
|
||||
|
20
hc/accounts/migrations/0008_profile_bill_to.py
Normal file
20
hc/accounts/migrations/0008_profile_bill_to.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.1 on 2017-06-08 11:58
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0007_profile_check_limit'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='profile',
|
||||
name='bill_to',
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
]
|
@ -38,6 +38,7 @@ class Profile(models.Model):
|
||||
token = models.CharField(max_length=128, blank=True)
|
||||
api_key = models.CharField(max_length=128, blank=True)
|
||||
current_team = models.ForeignKey("self", models.SET_NULL, null=True)
|
||||
bill_to = models.TextField(blank=True)
|
||||
|
||||
objects = ProfileManager()
|
||||
|
||||
|
20
hc/api/migrations/0032_auto_20170608_1158.py
Normal file
20
hc/api/migrations/0032_auto_20170608_1158.py
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.1 on 2017-06-08 11:58
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('api', '0031_auto_20170509_1320'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='channel',
|
||||
name='kind',
|
||||
field=models.CharField(choices=[('email', 'Email'), ('webhook', 'Webhook'), ('hipchat', 'HipChat'), ('slack', 'Slack'), ('pd', 'PagerDuty'), ('po', 'Pushover'), ('pushbullet', 'Pushbullet'), ('opsgenie', 'OpsGenie'), ('victorops', 'VictorOps'), ('discord', 'Discord'), ('telegram', 'Telegram')], max_length=20),
|
||||
),
|
||||
]
|
@ -25,6 +25,7 @@ class InvoiceTestCase(BaseTestCase):
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get("/invoice/abc123/")
|
||||
self.assertContains(r, "ABC123") # tx.id in uppercase
|
||||
self.assertContains(r, "alice@example.org") # bill to
|
||||
|
||||
@patch("hc.payments.views.braintree")
|
||||
def test_it_checks_customer_id(self, mock_braintree):
|
||||
@ -38,3 +39,18 @@ class InvoiceTestCase(BaseTestCase):
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get("/invoice/abc123/")
|
||||
self.assertEqual(r.status_code, 403)
|
||||
|
||||
@patch("hc.payments.views.braintree")
|
||||
def test_it_shows_company_data(self, mock_braintree):
|
||||
self.profile.bill_to = "Alice and Partners"
|
||||
self.profile.save()
|
||||
|
||||
tx = Mock()
|
||||
tx.id = "abc123"
|
||||
tx.customer_details.id = "test-customer-id"
|
||||
tx.created_at = None
|
||||
mock_braintree.Transaction.find.return_value = tx
|
||||
|
||||
self.client.login(username="alice@example.org", password="password")
|
||||
r = self.client.get("/invoice/abc123/")
|
||||
self.assertContains(r, "Alice and Partners")
|
||||
|
@ -53,7 +53,13 @@ VAT: LV44103100701
|
||||
</table>
|
||||
|
||||
<p><strong>Bill to:</strong></p>
|
||||
<p>{{ request.user.email }}</p>
|
||||
<p>
|
||||
{% if request.user.profile.bill_to %}
|
||||
{{ request.user.profile.bill_to|linebreaksbr }}
|
||||
{% else %}
|
||||
{{ request.user.email }}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
<p class="text-center">
|
||||
If you have a credit card on file it will be automatically charged within 24 hours.
|
||||
|
Loading…
x
Reference in New Issue
Block a user