Esempio n. 1
0
from conreq.core.base.forms import InitializationForm
from conreq.core.server_settings.models import ConreqConfig
from conreq.utils.generic import get_base_url, get_debug_from_env
from conreq.utils.testing import performance_metrics
from django.contrib.auth import authenticate, get_user_model, login
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.template import loader

from .helpers import initialize_conreq

base_url = get_base_url()
debug = get_debug_from_env()


@performance_metrics()
def main(request):
    """The primary view that handles whether to take the user to
    login, splash, initialization, or homepage."""
    conreq_config = ConreqConfig.get_solo()
    user_objects = get_user_model().objects

    # Authenticate using Organizr headers
    organizr_username = request.headers.get("X-WEBAUTH-USER")
    if conreq_config.conreq_http_header_auth and organizr_username:
        # Configure the user parameters
        organizr_email = request.headers.get("X-WEBAUTH-EMAIL")
        organizr_group = int(request.headers.get("X-WEBAUTH-GROUP"))
        user = user_objects.get_or_create(username=organizr_username, )[0]
        user.email = organizr_email
Esempio n. 2
0
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import include, path

from conreq.utils.generic import get_base_url, get_debug_from_env

DEBUG = get_debug_from_env()
BASE_URL = get_base_url()

urlpatterns = [
    path("", include("conreq.apps.base.urls")),
    path(
        BASE_URL + "sign_in/",
        auth_views.LoginView.as_view(
            redirect_authenticated_user=True,
            template_name="registration/sign_in.html"),
        name="sign_in",
    ),
    path(BASE_URL + "sign_out/", auth_views.logout_then_login,
         name="sign_out"),
    path(BASE_URL + "sign_up/", include("conreq.apps.sign_up.urls")),
    path(BASE_URL + "request/", include("conreq.apps.user_requests.urls")),
    # Viewport Locations
Esempio n. 3
0
from conreq.utils.generic import get_base_url, get_str_from_env
from django import template
from django.urls import reverse

register = template.Library()
base_url_len = len(get_base_url()) + 1
conreq_app_name = get_str_from_env("APP_NAME", "Conreq")
conreq_app_description = get_str_from_env("APP_DESCRIPTION",
                                          "Content Requesting")


@register.simple_tag
def viewport_url(namespace):
    url = reverse(namespace)
    return "#" + url[base_url_len:]


@register.simple_tag
def viewport_top_url(namespace):
    url = reverse(namespace)
    return "#" + "display/" + url[base_url_len:]


@register.simple_tag
def app_name():
    return conreq_app_name


@register.simple_tag
def app_description():
    return conreq_app_description