Payment Service 1
This commit is contained in:
@@ -214,12 +214,9 @@ class PaymentProcessingService:
|
||||
return self.charge_data.get("customer", None)
|
||||
|
||||
def _get_transaction_by_id(self):
|
||||
# print("self.webhook_data: ", self.webhook_data)
|
||||
# print("self.charge_data: ", self.charge_data)
|
||||
print("self.metadata: ", self.charge_data["metadata"])
|
||||
# Extract transaction_id from webhook metadata
|
||||
transaction_id = self.charge_data["metadata"]["transaction_id"]
|
||||
# Fetch the Transaction instance using the transaction_id
|
||||
print("_get_transaction_by_id: ", transaction_id)
|
||||
return Transaction.objects.get(id=int(transaction_id))
|
||||
|
||||
def _get_principal_subscription_by_id(self):
|
||||
@@ -402,7 +399,9 @@ class EventFilterService:
|
||||
@staticmethod
|
||||
def filter_events_by_search(search_query=None):
|
||||
today = timezone.now().date()
|
||||
filtered_events = Event.objects.filter(deleted=False, active=True, draft=False)
|
||||
filtered_events = Event.objects.filter(
|
||||
deleted=False, active=True, draft=False, created_by__is_active=True
|
||||
)
|
||||
|
||||
# Optional search filtering on title and key_guest (modify as needed)
|
||||
if search_query:
|
||||
@@ -428,7 +427,11 @@ class EventFilterService:
|
||||
if search_query:
|
||||
print("search_query: ", search_query)
|
||||
filtered_events = Event.objects.filter(
|
||||
tags__isnull=False, deleted=False, active=True, draft=False
|
||||
tags__isnull=False,
|
||||
deleted=False,
|
||||
active=True,
|
||||
draft=False,
|
||||
created_by__is_active=True,
|
||||
)
|
||||
|
||||
filtered_events = (
|
||||
@@ -457,9 +460,9 @@ class EventFilterService:
|
||||
today = timezone.now().date()
|
||||
events = Event.objects.none()
|
||||
|
||||
current_and_future_events_query = Q(active=True, deleted=False, draft=False) & (
|
||||
Q(start_date__lte=today, end_date__gte=today) | Q(start_date__gt=today)
|
||||
)
|
||||
current_and_future_events_query = Q(
|
||||
active=True, deleted=False, draft=False, created_by__is_active=True
|
||||
) & (Q(start_date__lte=today, end_date__gte=today) | Q(start_date__gt=today))
|
||||
|
||||
if filter_type == "expensive":
|
||||
events = Event.objects.filter(current_and_future_events_query).order_by(
|
||||
@@ -480,6 +483,7 @@ class EventFilterService:
|
||||
draft=False,
|
||||
active=True,
|
||||
deleted=False,
|
||||
created_by__is_active=True,
|
||||
).distinct()
|
||||
|
||||
return events
|
||||
@@ -488,9 +492,9 @@ class EventFilterService:
|
||||
def filter_events_by_category(category_id):
|
||||
today = timezone.now().date()
|
||||
|
||||
current_and_future_events_query = Q(active=True, deleted=False, draft=False) & (
|
||||
Q(start_date__lte=today, end_date__gte=today) | Q(start_date__gt=today)
|
||||
)
|
||||
current_and_future_events_query = Q(
|
||||
active=True, deleted=False, draft=False, created_by__is_active=True
|
||||
) & (Q(start_date__lte=today, end_date__gte=today) | Q(start_date__gt=today))
|
||||
|
||||
# Ensure the category_id is valid and within the specified range (1-8)
|
||||
if 1 <= category_id <= 8:
|
||||
@@ -516,7 +520,7 @@ class EventFilterService:
|
||||
| (Q(start_date__lte=tomorrow) & Q(end_date__gte=tomorrow))
|
||||
)
|
||||
events = Event.objects.filter(
|
||||
events_query, active=True, deleted=False, draft=False
|
||||
events_query, active=True, deleted=False, draft=False, created_by__is_active=True,
|
||||
).distinct()
|
||||
|
||||
return events
|
||||
@@ -532,6 +536,7 @@ class EventFilterService:
|
||||
draft=False,
|
||||
start_date__lte=today,
|
||||
end_date__gte=today,
|
||||
created_by__is_active=True,
|
||||
)
|
||||
|
||||
return events
|
||||
|
||||
@@ -412,15 +412,6 @@ def create_checkout_session(request):
|
||||
data = json.loads(request.body)
|
||||
print("data: ", data)
|
||||
subscription_id = data.get("subscriptionId", None)
|
||||
# if request.method == "GET":
|
||||
# subscription_id = None # Assuming 3 is a default or fallback subscription ID
|
||||
|
||||
# if request.user.is_authenticated:
|
||||
# print("request.user: ", request.user)
|
||||
# if request.user.principal_type.name == "event_user":
|
||||
# subscription_id = 2
|
||||
# elif request.user.principal_type.name == "event_manager":
|
||||
# subscription_id = 1
|
||||
|
||||
try:
|
||||
subscription = Subscription.objects.get(id=subscription_id)
|
||||
@@ -504,7 +495,6 @@ def create_checkout_session(request):
|
||||
"transaction_id": str(transaction.id),
|
||||
"principal_subscription_id": str(principal_subscription.id),
|
||||
},
|
||||
# Optionally, set shipping options, allow promotion codes, etc.
|
||||
)
|
||||
return JsonResponse({"sessionId": checkout_session["id"]})
|
||||
except Exception as e:
|
||||
|
||||
@@ -246,9 +246,9 @@
|
||||
<img loading="lazy" src="{% static '/images/menu-right-btn.png' %}" alt>
|
||||
</a>
|
||||
</div>
|
||||
<div class="Adventure-btn">
|
||||
<!-- <div class="Adventure-btn">
|
||||
<button class="common-btn">Join now</button>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
Reference in New Issue
Block a user