Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production #1902

Merged
merged 6 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/dashboard/coupon/coupon_view.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
from rest_framework.views import APIView
from utils.response import CustomResponse
from db.user import UserCouponLink
from rest_framework.response import Response





class CouponApi(APIView):
def post(self, request):
if coupon_code := request.data.get('data'):
if UserCouponLink.objects.filter(coupon=coupon_code).exists():

return CustomResponse(general_message="Coupon is valid").get_success_response()
return CustomResponse(general_message="Coupon is invalid").get_failure_response()
return CustomResponse(general_message="Coupon code is required").get_failure_response()

4 changes: 4 additions & 0 deletions api/dashboard/coupon/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
urlpatterns = [
path('verify-coupon/', coupon_view.CouponApi.as_view(), name='verify-coupon'),
]




2 changes: 2 additions & 0 deletions api/dashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
path('organisation/', include('api.dashboard.organisation.urls')),
path('dynamic-management/', include('api.dashboard.dynamic_management.urls')),
path('error-log/', include('api.dashboard.error_log.urls')),

path('affiliation/', include('api.dashboard.affiliation.urls')),
path('channels/', include('api.dashboard.channels.urls')),
path('discord-moderator/', include('api.dashboard.discord_moderator.urls')),
path('events/', include('api.dashboard.events.urls')),

path('coupon/', include('api.dashboard.coupon.urls')),

]
7 changes: 7 additions & 0 deletions db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ class Meta:
db_table = 'dynamic_user'





class UserCouponLink(models.Model):
id = models.CharField(primary_key=True, max_length=36)
user = models.ForeignKey('User', on_delete=models.CASCADE, related_name='usercouponlink_user')
Expand All @@ -219,4 +222,8 @@ class UserCouponLink(models.Model):

class Meta:
managed = False

db_table = 'user_coupon_link'



Loading