Skip to content

Commit

Permalink
Merge pull request #8 from ArabellaTech/source-for-charge
Browse files Browse the repository at this point in the history
adding source for charge
  • Loading branch information
jacoor committed Jun 30, 2017
2 parents 5943cfe + 82085ed commit cd4901a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## [0.2.9]
### Added
- added GenericForeignKey to StripeCharge as "source" field. Use https://docs.djangoproject.com/en/1.11/ref/contrib/contenttypes/#reverse-generic-relations for reverse lookup.

## [0.2.8]
### Changed
- changed relation on stripe models from to settings.STRIPE_USER_MODEL, which defaults to settings.AUTH_USER_MODEL. There are cases that CC is connected to, in example, office, not person.
Expand Down
2 changes: 1 addition & 1 deletion aa_stripe/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
__title__ = "Arabella Stripe"
__version__ = "0.2.8"
__version__ = "0.2.9"
__author__ = "Jacek Ostanski"
__license__ = "MIT"
__copyright__ = "Copyright 2017 Arabella"
Expand Down
27 changes: 27 additions & 0 deletions aa_stripe/migrations/0008_auto_20170630_0734.py
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-30 11:34
from __future__ import unicode_literals

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('aa_stripe', '0007_auto_20170630_0557'),
]

operations = [
migrations.AddField(
model_name='stripecharge',
name='content_type',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType'),
),
migrations.AddField(
model_name='stripecharge',
name='object_id',
field=models.PositiveIntegerField(db_index=True, null=True),
),
]
5 changes: 5 additions & 0 deletions aa_stripe/models.py
Expand Up @@ -4,6 +4,8 @@
import simplejson as json
import stripe
from django.conf import settings
from django.contrib.contenttypes import fields as generic
from django.contrib.contenttypes.models import ContentType
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.utils import timezone
Expand Down Expand Up @@ -64,6 +66,9 @@ class StripeCharge(StripeBasicModel):
stripe_charge_id = models.CharField(max_length=255, blank=True, db_index=True)
description = models.CharField(max_length=255, help_text=_("Description sent to Stripe"))
comment = models.CharField(max_length=255, help_text=_("Comment for internal information"))
content_type = models.ForeignKey(ContentType, null=True)
object_id = models.PositiveIntegerField(null=True, db_index=True)
source = generic.GenericForeignKey('content_type', 'object_id')

def charge(self):
if self.is_charged:
Expand Down

0 comments on commit cd4901a

Please sign in to comment.