Python django.conf.settings.VERSION Examples

The following are 16 code examples of django.conf.settings.VERSION(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source File: scale_scheduler.py    From scale with Apache License 2.0 6 votes vote down vote up
def handle(self, *args, **options):
        """See :meth:`django.core.management.base.BaseCommand.handle`.

        This method starts the scheduler.
        """

        # Register a listener to handle clean shutdowns
        signal.signal(signal.SIGTERM, self._onsigterm)

        # Set up global shutdown
        global GLOBAL_SHUTDOWN
        GLOBAL_SHUTDOWN = self._shutdown

        logger.info('Scale Scheduler %s', settings.VERSION)

        self.run_scheduler(settings.MESOS_MASTER) 
Example #2
Source File: views.py    From micromasters with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def terms_of_service(request):
    """
    Handles the terms of service page
    """
    return render(
        request,
        "terms_of_service.html",
        context={
            "has_zendesk_widget": True,
            "is_public": True,
            "js_settings_json": json.dumps({
                "release_version": settings.VERSION,
                "environment": settings.ENVIRONMENT,
                "sentry_dsn": settings.SENTRY_DSN,
                "user": serialize_maybe_user(request.user),
            }),
            "ga_tracking_id": "",
        }
    ) 
Example #3
Source File: settings.py    From raveberry with GNU Lesser General Public License v3.0 5 votes vote down vote up
def index(self, request: WSGIRequest) -> HttpResponse:
        """Renders the /settings page. Only admin is allowed to see this page."""
        if not self.base.user_manager.is_admin(request.user):
            raise PermissionDenied
        context = self.base.context(request)
        library_path = os.path.abspath(
            os.path.join(settings.SONGS_CACHE_DIR, "local_library")
        )
        if os.path.islink(library_path):
            context["local_library"] = os.readlink(library_path)
        else:
            context["local_library"] = "/"
        context["version"] = settings.VERSION
        return render(request, "settings.html", context) 
Example #4
Source File: context_processors.py    From telemetry-analysis-service with Mozilla Public License 2.0 5 votes vote down vote up
def version(request):
    """
    Adds version-related context variables to the context.
    """
    response = {}
    if django_settings.VERSION:
        response = {"version": django_settings.VERSION.get("version", None)}
        commit = django_settings.VERSION.get("commit")
        if commit:
            response["commit"] = commit[:7]
    return response 
Example #5
Source File: tests.py    From hawkpost with MIT License 5 votes vote down vote up
def test_about_page_rendered(self):
        response = self.client.get(reverse("pages_about"))
        self.assertEqual(response.status_code, 200)
        self.assertIn("pages/about.html", [t.name for t in response.templates])
        self.assertEqual(
            response.context["admin_name"], settings.SUPPORT_NAME)
        self.assertEqual(
            response.context["admin_email"], settings.SUPPORT_EMAIL)
        self.assertEqual(
            response.context["description"], settings.INSTANCE_DESCRIPTION)
        self.assertEqual(
            response.context["version"], settings.VERSION) 
Example #6
Source File: views.py    From hawkpost with MIT License 5 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context["admin_name"] = settings.SUPPORT_NAME
        context["admin_email"] = settings.SUPPORT_EMAIL
        context["description"] = settings.INSTANCE_DESCRIPTION
        context["version"] = settings.VERSION
        return context 
Example #7
Source File: version.py    From mangaki with GNU Affero General Public License v3.0 5 votes vote down vote up
def mangaki_version():
    return parse_mangaki_version(settings.VERSION) 
Example #8
Source File: version.py    From mangaki with GNU Affero General Public License v3.0 5 votes vote down vote up
def mangaki_revision():
    return parse_mangaki_revision(settings.VERSION) 
Example #9
Source File: views.py    From patchew with MIT License 5 votes vote down vote up
def render_page(request, template_name, **data):
    data["patchew_version"] = settings.VERSION + try_get_git_head()
    dispatch_module_hook("render_page_hook", request=request, context_data=data)
    return render(request, template_name, context=data) 
Example #10
Source File: processors.py    From bennedetto with GNU General Public License v3.0 5 votes vote down vote up
def constants(request):
    '''
    injects certain constants form settings module
    into template context
    '''
    return {'DEBUG': settings.DEBUG,
            'DOMAIN': settings.DOMAIN,
            'API_URL': settings.API_URL,
            'STATIC_URL': settings.STATIC_URL,
            'VERSION': settings.VERSION} 
Example #11
Source File: test_settings.py    From micromasters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_semantic_version():
        """
        Verify that we have a semantic compatible version.
        """
        semantic_version.Version(settings.VERSION) 
Example #12
Source File: views.py    From micromasters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def standard_error_page(request, status_code, template_filename):
    """
    Returns an error page with a given template filename and provides necessary context variables
    """
    name = request.user.profile.preferred_name if not request.user.is_anonymous else ""
    authenticated = not request.user.is_anonymous
    username = get_social_username(request.user)
    response = render(
        request,
        template_filename,
        context={
            "has_zendesk_widget": True,
            "is_public": True,
            "js_settings_json": json.dumps({
                "release_version": settings.VERSION,
                "environment": settings.ENVIRONMENT,
                "sentry_dsn": settings.SENTRY_DSN,
                "user": serialize_maybe_user(request.user),
            }),
            "authenticated": authenticated,
            "name": name,
            "username": username,
            "is_staff": has_role(request.user, [Staff.ROLE_ID, Instructor.ROLE_ID]),
            "support_email": settings.EMAIL_SUPPORT,
            "sentry_dsn": settings.SENTRY_DSN,
        }
    )
    response.status_code = status_code
    return response 
Example #13
Source File: models.py    From micromasters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_context(self, request, *args, **kwargs):
        programs = Program.objects.filter(live=True).select_related('programpage').order_by("id")
        benefits_page = BenefitsPage.objects.filter(live=True).first()
        js_settings = {
            "gaTrackingID": settings.GA_TRACKING_ID,
            "host": webpack_dev_server_host(request),
            "environment": settings.ENVIRONMENT,
            "sentry_dsn": settings.SENTRY_DSN,
            "release_version": settings.VERSION
        }

        username = get_social_username(request.user)
        context = super(HomePage, self).get_context(request)

        def get_program_page(program):
            """Return a None if ProgramPage does not exist, to avoid template errors"""
            try:
                return program.programpage
            except ProgramPage.DoesNotExist:
                return None

        program_pairs = [(program, get_program_page(program)) for program in programs]
        context["programs"] = program_pairs
        context["is_public"] = True
        context["has_zendesk_widget"] = True
        context["google_maps_api"] = False
        context["authenticated"] = not request.user.is_anonymous
        context["is_staff"] = has_role(request.user, [Staff.ROLE_ID, Instructor.ROLE_ID])
        context["username"] = username
        context["js_settings_json"] = json.dumps(js_settings)
        context["title"] = self.title
        context["ga_tracking_id"] = ""
        context["coupon_code"] = get_coupon_code(request)
        context["benefits_url"] = benefits_page.get_url() if benefits_page else ""

        return context 
Example #14
Source File: models.py    From micromasters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_program_page_context(programpage, request):
    """ Get context for the program page"""
    from cms.serializers import ProgramPageSerializer

    courses_query = (
        programpage.program.course_set.all()
    )
    js_settings = {
        "gaTrackingID": settings.GA_TRACKING_ID,
        "host": webpack_dev_server_host(request),
        "environment": settings.ENVIRONMENT,
        "sentry_dsn": settings.SENTRY_DSN,
        "release_version": settings.VERSION,
        "user": serialize_maybe_user(request.user),
        "program": ProgramPageSerializer(programpage).data,
    }
    username = get_social_username(request.user)
    context = super(ProgramPage, programpage).get_context(request)

    context["is_staff"] = has_role(request.user, [Staff.ROLE_ID, Instructor.ROLE_ID])
    context["is_public"] = True
    context["has_zendesk_widget"] = True
    context["google_maps_api"] = False
    context["authenticated"] = not request.user.is_anonymous
    context["username"] = username
    context["js_settings_json"] = json.dumps(js_settings)
    context["title"] = programpage.title
    context["courses"] = courses_query
    context["ga_tracking_id"] = programpage.program.ga_tracking_id

    return context 
Example #15
Source File: contexts.py    From loonflow with MIT License 5 votes vote down vote up
def global_variables(request):
    return {'VERSION': settings.VERSION} 
Example #16
Source File: views.py    From micromasters with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def get(self, request, *args, **kwargs):
        """
        Handle GET requests to templates using React
        """
        user = request.user
        roles = []
        if not user.is_anonymous:
            roles = [
                {
                    'program': role.program.id,
                    'role': role.role,
                    'permissions': [perm for perm, value in available_perm_status(user).items() if value is True]
                } for role in user.role_set.all()
            ]

        js_settings = {
            "gaTrackingID": settings.GA_TRACKING_ID,
            "reactGaDebug": settings.REACT_GA_DEBUG,
            "host": webpack_dev_server_host(request),
            "edx_base_url": settings.EDXORG_BASE_URL,
            "roles": roles,
            "release_version": settings.VERSION,
            "environment": settings.ENVIRONMENT,
            "sentry_dsn": settings.SENTRY_DSN,
            "search_url": reverse('search_api', kwargs={"elastic_url": ""}),
            "support_email": settings.EMAIL_SUPPORT,
            "user": serialize_maybe_user(request.user),
            "es_page_size": settings.ELASTICSEARCH_DEFAULT_PAGE_SIZE,
            "public_path": public_path(request),
            "EXAMS_SSO_CLIENT_CODE": settings.EXAMS_SSO_CLIENT_CODE,
            "EXAMS_SSO_URL": settings.EXAMS_SSO_URL,
            "FEATURES": {
                "PROGRAM_LEARNERS": settings.FEATURES.get('PROGRAM_LEARNERS_ENABLED', False),
                "DISCUSSIONS_POST_UI": settings.FEATURES.get('OPEN_DISCUSSIONS_POST_UI', False),
                "DISCUSSIONS_CREATE_CHANNEL_UI": settings.FEATURES.get('OPEN_DISCUSSIONS_CREATE_CHANNEL_UI', False),
                "PROGRAM_RECORD_LINK": settings.FEATURES.get('PROGRAM_RECORD_LINK', False),
                "ENABLE_PROGRAM_LETTER": settings.FEATURES.get('ENABLE_PROGRAM_LETTER', False)
            },
            "open_discussions_redirect_url": settings.OPEN_DISCUSSIONS_REDIRECT_URL,
        }

        return render(
            request,
            "dashboard.html",
            context={
                "has_zendesk_widget": True,
                "is_public": False,
                "google_maps_api": False,
                "js_settings_json": json.dumps(js_settings),
                "ga_tracking_id": "",
            }
        )