Skip to content

Commit

Permalink
Merge pull request #1902 from gtech-mulearn/production
Browse files Browse the repository at this point in the history
Production
  • Loading branch information
Jenin82 authored Apr 17, 2024
2 parents d94ee50 + 3e5929c commit e514b5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
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'



0 comments on commit e514b5b

Please sign in to comment.