Skip to content

Commit

Permalink
fix: room links must have higher prio than chats
Browse files Browse the repository at this point in the history
  • Loading branch information
vas3k committed Dec 7, 2024
1 parent d239170 commit 151dbae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
10 changes: 9 additions & 1 deletion frontend/html/rooms/list_rooms.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@
<span class="room-icon feed-topic-header-icon"><img src="{{ room.image }}" alt="Иконка комнаты {{ room.title }}" loading="lazy" /></span>
<a href="{% url "feed_room" room.slug %}" class="feed-topic-header-name">{{ room.title }}</a>
</div>

<span class="feed-topic-header-desctiption">
{{ room.description | markdown }}
</span>

{% if room.url %}
<span class="feed-topic-header-footer">
<i class="fas fa-link"></i>&nbsp;<strong>URL:</strong> <a href="{{ room.url }}" rel="noreferrer" target="_blank">{{ room.url }}</a>
</span>
{% endif %}

{% if room.chat_url and room.chat_name %}
<span class="feed-topic-header-footer">
<i class="fab fa-telegram-plane"></i>&nbsp;<strong>Официальный чат:</strong> <a href="{{ room.get_private_url }}" rel="noreferrer" target="_blank">{{ room.chat_name }}</a>
<i class="fab fa-telegram-plane"></i>&nbsp;<strong>Чат:</strong> <a href="{{ room.get_private_url }}" rel="noreferrer" target="_blank">{{ room.chat_name }}</a>
</span>
{% endif %}
</div>
Expand Down
35 changes: 22 additions & 13 deletions payments/views/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render
from stripe.error import InvalidRequestError

from authn.decorators.auth import require_auth
from club.exceptions import BadRequest
Expand Down Expand Up @@ -115,19 +116,27 @@ def pay(request):
customer_data = dict(customer_email=user.email)

# create stripe session and payment (to keep track of history)
session = stripe.checkout.Session.create(
payment_method_types=["card"],
line_items=[{
"price": product["stripe_id"],
"quantity": 1,
}],
**customer_data,
mode="subscription" if is_recurrent else "payment",
metadata=payment_data,
automatic_tax={"enabled": True},
success_url=settings.STRIPE_SUCCESS_URL,
cancel_url=settings.STRIPE_CANCEL_URL,
)
try:
session = stripe.checkout.Session.create(
payment_method_types=["card"],
line_items=[{
"price": product["stripe_id"],
"quantity": 1,
}],
**customer_data,
mode="subscription" if is_recurrent else "payment",
metadata=payment_data,
automatic_tax={"enabled": True},
success_url=settings.STRIPE_SUCCESS_URL,
cancel_url=settings.STRIPE_CANCEL_URL,
)
except InvalidRequestError as ex:
log.exception(ex)
return render(request, "error.html", {
"title": "Ошибка при создании платежа",
"message": "Невалидный email или выбранный пакет не найден. "
"Попробуйте обновить страницу. Если ошибка повторится, напишите нам в поддержку."
})

payment = Payment.create(
reference=session.id,
Expand Down
6 changes: 3 additions & 3 deletions rooms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def list_rooms(request):
@require_auth
def redirect_to_room_chat(request, room_slug):
room = get_object_or_404(Room, slug=room_slug)
if room.chat_url:
return redirect(room.chat_url, permanent=False)
elif room.url:
if room.url:
return redirect(room.url, permanent=False)
elif room.chat_url:
return redirect(room.chat_url, permanent=False)
else:
raise Http404()

Expand Down

0 comments on commit 151dbae

Please sign in to comment.