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

Add Video-Component Logic to User's Dashboard #314

Closed
wants to merge 3 commits into from
Closed
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
98 changes: 38 additions & 60 deletions src/pretix/control/templates/pretixcontrol/auth/base.html
Original file line number Diff line number Diff line change
@@ -1,67 +1,45 @@
{% load compress %}
{% extends "pretixcontrol/auth/base.html" %}
{% load bootstrap3 %}
{% load i18n %}
{% load hijack_tags %}
{% load static %}
<!DOCTYPE html>
<html{% if rtl %} dir="rtl" class="rtl"{% endif %}>
<head>
<title>{{ django_settings.INSTANCE_NAME }}</title>
{% compress css %}
<link rel="stylesheet" type="text/x-scss" href="{% static "pretixcontrol/scss/auth.scss" %}"/>
{% endcompress %}
<meta name="viewport" content="width=device-width, initial-scale=1">

{% if development_warning or debug_warning %}
<link rel="shortcut icon" href="{% static "pretixbase/img/favicon-debug.ico" %}">
{% else %}
<link rel="shortcut icon" href="{% static "pretixbase/img/favicon.ico" %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static "pretixbase/img/icons/favicon-32x32.png" %}">
<link rel="icon" type="image/png" sizes="194x194" href="{% static "pretixbase/img/icons/favicon-194x194.png" %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static "pretixbase/img/icons/favicon-16x16.png" %}">
{% endif %}
<link rel="apple-touch-icon" sizes="180x180" href="{% static "pretixbase/img/icons/apple-touch-icon.png" %}">
<link rel="icon" type="image/png" sizes="192x192" href="{% static "pretixbase/img/icons/android-chrome-192x192.png" %}">
<link rel="manifest" href="{% url "presale:site.webmanifest" %}">
<link rel="mask-icon" href="{% static "pretixbase/img/icons/safari-pinned-tab.svg" %}" color="#2185d0">
<meta name="msapplication-TileColor" content="#2185d0">
<meta name="msapplication-config" content="{% url "presale:browserconfig.xml" %}">
<meta name="theme-color" content="#2185d0">
</head>
<body>
{% block content %}
<div class="container">
<a href="{% url "control:auth.login" %}">
<img src="{% static "pretixbase/img/eventyay-logo.svg" %}" class="logo"/>
</a>
{% if messages %}
{% for message in messages %}
<div class="alert {{ message.tags }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% if request|is_hijacked %}
<div class="impersonate-warning">
<span class="fa fa-user-secret"></span>
{% blocktrans with user=request.user%}You are currently working on behalf of {{ user }}.{% endblocktrans %}
<div class="form-wrapper">
<div class="form-signin">
<h3>{% trans "Components" %}</h3>
<p>
{% blocktrans trimmed with a_attr="href='https://eventyay.com'" %}
This is a self-hosted installation of <a {{ a_attr }}>eventyay, your open source event solution</a>.
{% endblocktrans %}
</p>

<form action="{% url 'control:users.impersonate.stop' %}" method="post" class="helper-display-inline">
{% csrf_token %}
<button class="btn btn-default btn-sm">
{% trans "Stop impersonating" %}
</button>
</form>
</div>
{% endif %}
<!-- Eventyay-Talk Component -->
{% if is_eventyay_talk_installed %}
<p>
<a href="{% url 'eventyay-talk' %}" class="btn btn-primary">
{% trans "Go to Eventyay-Talk" %}
</a>
</p>
{% else %}
<p>
{% trans "Eventyay-Talk is not installed." %}
</p>
{% endif %}

{% block content %}
{% endblock %}
<footer>
{% with "href='https://eventyay.com'" as a_attr %}
{% blocktrans trimmed %}
powered by <a {{ a_attr }}>eventyay</a>
{% endblocktrans %}
{% endwith %}
</footer>
<!-- Eventyay-Video Component -->
{% if is_eventyay_video_installed %}
<p>
<a href="{% url 'eventyay-video' %}" class="btn btn-primary">
{% trans "Go to Eventyay-Video" %}
</a>
</p>
{% else %}
<p>
{% trans "Eventyay-Video is not installed." %}
</p>
{% endif %}
</div>
</div>
</div>
</body>
</html>
{% endblock %}
45 changes: 45 additions & 0 deletions src/pretix/control/templates/pretixcontrol/auth/components.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends "pretixcontrol/auth/base.html" %}
{% load bootstrap3 %}
{% load i18n %}
{% load static %}

{% block content %}
<div class="container">
<div class="form-wrapper">
<div class="form-signin">
<h3>{% trans "Components" %}</h3>
<p>
{% blocktrans trimmed with a_attr="href='https://eventyay.com'" %}
This is a self-hosted installation of <a {{ a_attr }}>eventyay, your open source event solution</a>.
{% endblocktrans %}
</p>

<!-- Eventyay-Talk Component -->
{% if is_eventyay_talk_installed %}
<p>
<a href="{% url 'eventyay-talk' %}" class="btn btn-primary">
{% trans "Go to Eventyay-Talk" %}
</a>
</p>
{% else %}
<p>
{% trans "Eventyay-Talk is not installed." %}
</p>
{% endif %}

<!-- Eventyay-Video Component -->
{% if is_eventyay_video_installed %}
<p>
<a href="{% url 'eventyay-video' %}" class="btn btn-primary">
{% trans "Go to Eventyay-Video" %}
</a>
</p>
{% else %}
<p>
{% trans "Eventyay-Video is not installed." %}
</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions src/pretix/control/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
url(r'^invite/(?P<token>[a-zA-Z0-9]+)$', auth.invite, name='auth.invite'),
url(r'^forgot$', auth.Forgot.as_view(), name='auth.forgot'),
url(r'^forgot/recover$', auth.Recover.as_view(), name='auth.forgot.recover'),
url('auth/components/', auth.ComponentsView, name='auth.components'),
url(r'^$', dashboards.user_index, name='index'),
url(r'^widgets.json$', dashboards.user_index_widgets_lazy, name='index.widgets'),
url(r'^global/settings/$', global_settings.GlobalSettingsView.as_view(), name='global.settings'),
Expand Down
19 changes: 19 additions & 0 deletions src/pretix/control/views/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import time
import os
from urllib.parse import quote

import webauthn
Expand All @@ -10,6 +11,7 @@
authenticate, login as auth_login, logout as auth_logout,
)
from django.contrib.auth.tokens import default_token_generator
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.shortcuts import redirect, render
Expand Down Expand Up @@ -439,3 +441,20 @@ def get_context_data(self, **kwargs):

def get(self, request, *args, **kwargs):
return super().get(request, *args, **kwargs)


@login_required
def ComponentsView(request):
try:
AviGawande marked this conversation as resolved.
Show resolved Hide resolved
base_directory = settings.BASE_DIR
parent_directory = os.path.abspath(os.path.join(base_directory, os.pardir))
eventyay_video_path = os.path.join(parent_directory, 'eventyay-video')
is_eventyay_video_installed = os.path.isdir(eventyay_video_path)
context = {
'is_eventyay_video_installed': is_eventyay_video_installed,
'eventyay_video_path': eventyay_video_path if is_eventyay_video_installed else None,
}
return render(request, 'pretixcontrol/auth/components.html', context)
except Exception as e:
logger.error(f"Error in ComponentsView: {str(e)}")
return render(request, 'pretixcontrol/auth/components.html', {'error': 'An error occurred while checking components.'})
2 changes: 2 additions & 0 deletions src/pretix/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,5 @@
HAS_GEOIP = True
GEOIP_PATH = config.get('geoip', 'path')
GEOIP_COUNTRY = config.get('geoip', 'filename_country', fallback='GeoLite2-Country.mmdb')

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
AviGawande marked this conversation as resolved.
Show resolved Hide resolved