Skip to content

Commit

Permalink
Merge pull request #671 from srahulbadami/stripeIntegration
Browse files Browse the repository at this point in the history
Added Stripe Integration/ Bug Hunt Winner Selection Logic & Winner Payment Logic
  • Loading branch information
souravbadami authored Aug 29, 2020
2 parents 51763d2 + 7738fd6 commit 0af7b1b
Show file tree
Hide file tree
Showing 33 changed files with 4,037 additions and 302 deletions.
8 changes: 7 additions & 1 deletion bugheist/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,10 @@
'toolbar': ["undo", "redo", "|","bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|","h1", "h2", "h3", "h5", "h6", "|","list-ul", "list-ol", "hr", "|", "link", "reference-link", "code", "code-block", "table", "datetime", "||", "preview", "fullscreen"],
'watch' : False
}
}
}

STRIPE_LIVE_PUBLIC_KEY = os.environ.get("STRIPE_LIVE_PUBLIC_KEY", "<your publishable key>")
STRIPE_LIVE_SECRET_KEY = os.environ.get("STRIPE_LIVE_SECRET_KEY", "<your secret key>")
STRIPE_TEST_PUBLIC_KEY = os.environ.get("STRIPE_TEST_PUBLIC_KEY", "pk_test_51HFiXMFf0OkkOVnDkNs4opFLqM0Sx5GA6Pedf63uGzG1gHhumFYHEOLfCA7yzZwXUpjaa5j9ZhS1yciNhouYCMh400pSx5ZEx6")
STRIPE_TEST_SECRET_KEY = os.environ.get("STRIPE_TEST_SECRET_KEY", "sk_test_51HFiXMFf0OkkOVnDiAnuYiq6JInx3VSXw2HzIV6ihGWzaO8un5djIi990OCLTAv5PRnY7Yl8v8yuxf6yU47gvKYj00hkKaKaQ0")
STRIPE_LIVE_MODE = False # Change to True in production
12 changes: 10 additions & 2 deletions bugheist/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
HuntCreate, DomainDetailView, StatsDetailView, InviteCreate, CreateInviteFriend,
ScoreboardView,get_score,CustomObtainAuthToken,create_tokens,issue_count,get_scoreboard,
CreateHunt, DraftHunts, UpcomingHunts, CompanySettings, OngoingHunts, PreviousHunts,
DomainList, UserProfileDetailsView )
DomainList, UserProfileDetailsView, JoinCompany )
from rest_framework.authtoken import views

favicon_view = RedirectView.as_view(url='/static/favicon.ico', permanent=True)
Expand All @@ -26,21 +26,29 @@
urlpatterns = [
url(r'^$', website.views.index, name='index'),
url(r'^dashboard/company/$', website.views.company_dashboard, name='company_dashboar_home'),
url(r'^dashboard/user/profile/addbalance$', website.views.addbalance, name='addbalance'),
url(r'^dashboard/user/profile/withdraw$', website.views.withdraw, name='withdraw'),
url(r'^dashboard/user/stripe/connected/(?P<username>[^/]+)/$', website.views.stripe_connected, name='stripe_connected'),
url(r'^dashboard/admin$', website.views.admin_dashboard, name='admin_dashboard'),
url(r'^dashboard/admin/company$', website.views.admin_company_dashboard, name='admin_company_dashboard'),
url(r'^dashboard/admin/company/addorupdate$', website.views.add_or_update_company, name='add_or_update_company'),
url(r'^dashboard/company/domain/addorupdate$', website.views.add_or_update_domain, name='add_or_update_domain'),
path('dashboard/company/domain/<int:pk>/', website.views.company_dashboard_domain_detail, name='company_dashboard_domain_detail'),
path('dashboard/company/hunt/<int:pk>/', website.views.company_dashboard_hunt_detail, name='company_dashboard_hunt_detail'),
path('dashboard/user/hunt/<int:pk>/', website.views.view_hunt, name='view_hunt'),
path('dashboard/user/hunt/<int:pk>/submittion/', website.views.submit_bug, name='submit_bug'),
path('dashboard/user/hunt/<int:pk>/results/', website.views.hunt_results, name='hunt_results'),
path('dashboard/company/hunt/<int:pk>/edit', website.views.company_dashboard_hunt_edit, name='company_dashboard_hunt_edit'),
path('dashboard/admin/company/<int:pk>/', website.views.admin_company_dashboard_detail, name='admin_company_dashboard_detail'),
url(r'^dashboard/company/hunt/create$', CreateHunt.as_view(), name='create_hunt'),
url(r'^dashboard/company/hunt/drafts$', DraftHunts.as_view(), name='draft_hunts'),
url(r'^dashboard/company/hunt/upcoming$', UpcomingHunts.as_view(), name='upcoming_hunts'),
url(r'^dashboard/company/hunt/previous$', PreviousHunts.as_view(), name='previous_hunts'),
path('dashboard/company/hunt/previous/<int:pk>/', website.views.company_hunt_results, name='company_hunt_results'),
url(r'^dashboard/company/hunt/ongoing$', OngoingHunts.as_view(), name='ongoing_hunts'),
url(r'^dashboard/company/domains$', DomainList.as_view(), name='domain_list'),
url(r'^dashboard/company/settings$', CompanySettings.as_view(), name='company-settings'),
url(r'^join$', JoinCompany.as_view(), name='join'),
url(r'^dashboard/company/settings/role/update$', website.views.update_role, name='update-role'),
url(r'^dashboard/company/settings/role/add$', website.views.add_role, name='add-role'),
url(r'^dashboard/user/$', website.views.user_dashboard, name='user'),
Expand Down Expand Up @@ -100,7 +108,7 @@
url(r'^api/v1/', include(router.urls)),
url(r'^api/v1/userscore/$', website.views.get_score),
url(r'^authenticate/', CustomObtainAuthToken.as_view()),
url(r'^api/v1/create_tokens/$', website.views.create_tokens),
url(r'^api/v1/createwallet/$', website.views.create_wallet),
url(r'^api/v1/count/$', website.views.issue_count),
url(r'^api/v1/createissues/$', csrf_exempt(IssueCreate.as_view()), name="issuecreate"),
url(r'^api/v1/delete_issue/(?P<id>\w+)/$', csrf_exempt(website.views.delete_issue)),
Expand Down
34 changes: 32 additions & 2 deletions website/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from import_export import resources
from import_export.admin import ImportExportModelAdmin

from website.models import Issue, Points, Hunt, Domain, UserProfile, Subscription, CompanyAdmin, Company
from website.models import Winner, Payment, Transaction, Wallet, Issue, Points, Hunt, Domain, UserProfile, Subscription, CompanyAdmin, Company


class UserResource(resources.ModelResource):
Expand All @@ -28,6 +28,33 @@ class CompanyResource(resources.ModelResource):
class Meta:
model = Company

class WalletResource(resources.ModelResource):
class Meta:
model = Wallet


class WinnerResource(resources.ModelResource):
class Meta:
model = Winner


class PaymentResource(resources.ModelResource):
class Meta:
model = Payment


class WinnerAdmin(admin.ModelAdmin):
list_display = (
'id', 'hunt', 'winner', 'runner', 'second_runner', 'prize_distributed')

class WalletAdmin(admin.ModelAdmin):
list_display = (
'id', 'user', 'current_balance', 'created_at')

class PaymentAdmin(admin.ModelAdmin):
list_display = (
'id', 'wallet', 'value', 'active')


class IssueAdmin(admin.ModelAdmin):
list_display = (
Expand Down Expand Up @@ -87,4 +114,7 @@ class UserAdmin(ImportExportModelAdmin):
admin.site.register(CompanyAdmin, CompanyUserAdmin)
admin.site.register(Company, CompanyAdmins)

admin.site.register(Subscription, SubscriptionAdmin)
admin.site.register(Subscription, SubscriptionAdmin)
admin.site.register(Wallet, WalletAdmin)
admin.site.register(Winner, WinnerAdmin)
admin.site.register(Payment, PaymentAdmin)
35 changes: 35 additions & 0 deletions website/migrations/0059_transaction_wallet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 3.0.8 on 2020-08-18 09:16

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('website', '0058_userprofile_description'),
]

operations = [
migrations.CreateModel(
name='Wallet',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('current_balance', models.DecimalField(decimal_places=2, default=0, max_digits=6)),
('created_at', models.DateTimeField(auto_now_add=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Transaction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('value', models.DecimalField(decimal_places=2, max_digits=6)),
('running_balance', models.DecimalField(decimal_places=2, max_digits=6)),
('created_at', models.DateTimeField(auto_now_add=True)),
('wallet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='website.Wallet')),
],
),
]
18 changes: 18 additions & 0 deletions website/migrations/0060_wallet_account_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.8 on 2020-08-19 06:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('website', '0059_transaction_wallet'),
]

operations = [
migrations.AddField(
model_name='wallet',
name='account_id',
field=models.TextField(blank=True, null=True),
),
]
23 changes: 23 additions & 0 deletions website/migrations/0061_payment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.0.8 on 2020-08-19 08:44

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


class Migration(migrations.Migration):

dependencies = [
('website', '0060_wallet_account_id'),
]

operations = [
migrations.CreateModel(
name='Payment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('value', models.DecimalField(decimal_places=2, max_digits=6)),
('active', models.BooleanField(default=True)),
('wallet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='website.Wallet')),
],
),
]
18 changes: 18 additions & 0 deletions website/migrations/0062_company_is_active.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.8 on 2020-08-22 09:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('website', '0061_payment'),
]

operations = [
migrations.AddField(
model_name='company',
name='is_active',
field=models.BooleanField(default=False),
),
]
28 changes: 28 additions & 0 deletions website/migrations/0063_auto_20200826_0351.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.0.8 on 2020-08-26 03:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('website', '0062_company_is_active'),
]

operations = [
migrations.AddField(
model_name='hunt',
name='prize_runner',
field=models.DecimalField(decimal_places=2, default=0, max_digits=6),
),
migrations.AddField(
model_name='hunt',
name='prize_second_runner',
field=models.DecimalField(decimal_places=2, default=0, max_digits=6),
),
migrations.AddField(
model_name='hunt',
name='prize_winner',
field=models.DecimalField(decimal_places=2, default=0, max_digits=6),
),
]
19 changes: 19 additions & 0 deletions website/migrations/0064_issue_hunt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.0.8 on 2020-08-26 16:41

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


class Migration(migrations.Migration):

dependencies = [
('website', '0063_auto_20200826_0351'),
]

operations = [
migrations.AddField(
model_name='issue',
name='hunt',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='website.Hunt'),
),
]
23 changes: 23 additions & 0 deletions website/migrations/0065_auto_20200826_1809.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.0.8 on 2020-08-26 18:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('website', '0064_issue_hunt'),
]

operations = [
migrations.AddField(
model_name='issue',
name='score',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='issue',
name='verified',
field=models.BooleanField(default=False),
),
]
28 changes: 28 additions & 0 deletions website/migrations/0066_auto_20200827_1733.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.0.8 on 2020-08-27 17:33

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('website', '0065_auto_20200826_1809'),
]

operations = [
migrations.AddField(
model_name='hunt',
name='result_published',
field=models.BooleanField(default=False),
),
migrations.CreateModel(
name='Winner',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
40 changes: 40 additions & 0 deletions website/migrations/0067_auto_20200827_1738.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 3.0.8 on 2020-08-27 17:38

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


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('website', '0066_auto_20200827_1733'),
]

operations = [
migrations.RemoveField(
model_name='winner',
name='user',
),
migrations.AddField(
model_name='winner',
name='prize_distributed',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='winner',
name='runner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='runner', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='winner',
name='second_runner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='second_runner', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='winner',
name='winner',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='winner', to=settings.AUTH_USER_MODEL),
),
]
19 changes: 19 additions & 0 deletions website/migrations/0068_winner_hunt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.0.8 on 2020-08-28 15:35

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


class Migration(migrations.Migration):

dependencies = [
('website', '0067_auto_20200827_1738'),
]

operations = [
migrations.AddField(
model_name='winner',
name='hunt',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='website.Hunt'),
),
]
Loading

0 comments on commit 0af7b1b

Please sign in to comment.