#1 Перенос изменений в основную ветку

Nyitott
1Mike21 szeretne 20 commit-ot egyesíteni innen: ShariX_Open/unstable ide: ShariX_Open/master

+ 0 - 0
__init__.py


+ 3 - 0
admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 10 - 0
apps.py

@@ -0,0 +1,10 @@
+from django.apps import AppConfig
+
+class DesignTemplateConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'design_template'  
+        
+    
+#colors = ['#479FF8', '#ffffff', '#0a58ca', '#0d6efd', '#ffffff', '#0d6efd', '#0a58ca','#198754', '#198754', '#10683f', '#ffffff', '#dc3545', '#821e27', '#ffffff']
+
+  

+ 4 - 0
context_processors.py

@@ -0,0 +1,4 @@
+from core import settings
+
+def get_name_system(request):
+    return {'NameSystem':settings.NAME_SYSTEM} 

+ 29 - 0
forms.py

@@ -0,0 +1,29 @@
+from django import forms
+import re
+class LogoForm(forms.Form):
+    namesystem = forms.CharField(max_length=30, label="Название системы", required=False)
+    logo = forms.FileField(label="Логотип", required=False)
+    logo.widget.attrs.update({'accept':'.png, .svg, .ico'})
+
+class ColorsForm(forms.Form):
+    def __init__(self, *args, **kwargs):
+        # Read the color codes from the CSS file and append additional colors
+        f = str((open('design_template/static/design_template/colors.css', encoding='utf-8')).read())
+        color_codes_list = re.findall(r'#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}', f)
+        colors = color_codes_list
+        super(ColorsForm, self).__init__(*args, **kwargs)
+
+        # Create form fields with initial color values
+        self.fields['btnBg'] = forms.CharField(label='Цвет кнопок', initial=colors[0], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnTxt'] = forms.CharField(label='Цвет текста кнопок', initial=colors[1], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnHover'] = forms.CharField(label='Цвет наведения у кнопок', initial=colors[2], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['pillsBg'] = forms.CharField(label='Цвет плашек в меню', initial=colors[3], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['pillsTxt'] = forms.CharField(label='Цвет текста плашек в меню', initial=colors[4], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['linksTxt'] = forms.CharField(label='Цвет текста ссылок', initial=colors[5], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['linksHover'] = forms.CharField(label='Цвет наведения у ссылок', initial=colors[6], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnSuccessBg'] = forms.CharField(label='Цвет кнопок успеха', initial=colors[7], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnSuccessTxt'] = forms.CharField(label='Цвет текста кнопок успеха', initial=colors[8], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnSuccessHover'] = forms.CharField(label='Цвет наведения у кнопок успеха', initial=colors[9], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnDangerBg'] = forms.CharField(label='Цвет текста кнопок предупреждения', initial=colors[10], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnDangerTxt'] = forms.CharField(label='Цвет текста кнопок предупреждения', initial=colors[11], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))
+        self.fields['btnDangerHover'] = forms.CharField(label='Цвет наведения у кнопок предупреждения', initial=colors[12], max_length=7, widget=forms.TextInput(attrs={'type': 'color'}))

+ 3 - 0
models.py

@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.

+ 71 - 0
static/design_template/colors.css

@@ -0,0 +1,71 @@
+
+:root{
+  --btn-bg-color: #fdb4b4;
+  --btn-txt-color: #ff0000;
+  --btn-hover-color: #0a58ca;
+  --pills-bg-color: #0d6efd;
+  --pills-txt-color: None;
+  --links-txt-color: #821e27;
+  --links-hover-color: #821e27;
+  --btn-success: #821e27;
+  --btn-success-txt: #821e27;
+  --btn-success-hover: #821e27;
+  --btn-danger: #821e27;
+  --btn-danger-txt: #821e27;
+  --btn-danger-hover: #821e27;
+}
+
+.btn-primary, .btn-outline-primary{
+  background-color: var(--btn-bg-color);
+  color: var(--btn-txt-color);
+  border-color: var(--btn-bg-color);
+}
+
+.btn-primary:hover, .btn-outline-primary:hover{
+  background-color: var(--btn-hover-color);
+  border-color: var(--btn-hover-color);
+}
+
+.nav-pills .nav-link.active, .nav-pills .show>.nav-link{
+  background-color: var(--pills-bg-color);
+  color: var(--pills-txt-color);
+}
+
+a{
+ color: var(--links-txt-color); 
+}
+
+a:hover{
+  color:var(--links-hover-color)
+}
+
+.nav-link{
+  color: var(--links-txt-color)
+}
+
+.nav-link:hover{
+  color:var(--links-hover-color)
+}
+
+.btn-success, .btn-outline-success{
+  color: var(--btn-txt-color);
+  background-color: var(--btn-success);
+  border-color: var(--btn-success);
+}
+
+.btn-success:hover, .btn-outline-success:hover{
+  background-color: var(--btn-success-hover);
+  border-color: var(--btn-success-hover);
+}
+
+.btn-danger, .btn-outline-danger{
+  color: var(--btn-danger-txt);
+  background-color: var(--btn-danger);
+  border-color: var(--btn-danger);
+}
+
+.btn-danger:hover, .btn-outline-danger:hover{
+  background-color: var(--btn-danger-hover);
+  border-color: var(--btn-danger-hover);
+}
+

+ 397 - 0
templates/admin/base.html

@@ -0,0 +1,397 @@
+{% load i18n static jazzmin admin_urls %}
+{% get_current_language as LANGUAGE_CODE %}
+{% get_current_language_bidi as LANGUAGE_BIDI %}
+{% get_jazzmin_settings request as jazzmin_settings %}
+{% get_jazzmin_ui_tweaks as jazzmin_ui %}
+
+<!DOCTYPE html>
+<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+    <!--  Prevent admin panel being crawled by search engines -->
+    <meta name="robots" content="none, noarchive">
+
+    <title>{% block title %}{{ title }} | {{ jazzmin_settings.site_title }}{% endblock %}</title>
+
+    <!-- Font Awesome Icons -->
+    <link rel="stylesheet" href="{% static "vendor/fontawesome-free/css/all.min.css" %}">
+
+    <!-- Bootstrap and adminLTE -->
+    <link rel="stylesheet" href="{% static "vendor/adminlte/css/adminlte.min.css" %}" id="adminlte-css">
+
+    <!-- Bootswatch theme -->
+    {% if jazzmin_ui.theme.name != 'default' %}
+        <link rel="stylesheet" href="{{ jazzmin_ui.theme.src }}" id="jazzmin-theme" />
+    {% endif %}
+
+    {% if jazzmin_ui.dark_mode_theme %}
+        <link rel="stylesheet" href="{{ jazzmin_ui.dark_mode_theme.src }}" id="jazzmin-dark-mode-theme" media="(prefers-color-scheme: dark)"/>
+    {% endif %}
+
+    <!-- Custom fixes for django -->
+    <link rel="stylesheet" href="{% static "jazzmin/css/main.css" %}">
+
+    {% if jazzmin_settings.custom_css %}
+    <!-- Custom CSS -->
+    <link rel="stylesheet" href="{% static jazzmin_settings.custom_css %}">
+    {% endif %}
+
+    <!-- favicons -->
+    <link rel="shortcut icon" href="{% static jazzmin_settings.site_icon %}" type="image/png">
+    <link rel="icon" href="{% static jazzmin_settings.site_icon %}" sizes="32x32" type="image/png">
+
+    {% if jazzmin_settings.use_google_fonts_cdn %}
+    <!-- Google Font: Source Sans Pro -->
+    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
+    {% endif %}
+
+    {% block extrastyle %} {% endblock %}
+    {% block extrahead %} {% endblock %}
+</head>
+<body class="hold-transition{% if not jazzmin_settings.show_sidebar %} no-sidebar{% else %} sidebar-mini{% endif %} {% sidebar_status request %} {% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %} {{ jazzmin_ui.body_classes }} {% if jazzmin_ui.dark_mode_theme %}theme-dark{% endif %}" data-admin-utc-offset="{% now "Z" %}">
+
+<div class="wrapper">
+
+    {% if not is_popup %}
+        <nav class="main-header navbar navbar-expand {{ jazzmin_ui.navbar_classes }}" id="jazzy-navbar">
+            <ul class="navbar-nav">
+
+                {% if jazzmin_settings.show_sidebar %}
+                    <li class="nav-item">
+                        <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
+                    </li>
+                {% else %}
+                    <li class="nav-item">
+                        <a href="{% url 'admin:index' %}" class="brand-link">
+                            <img src="{% static jazzmin_settings.site_logo %}" alt="{{ jazzmin_settings.site_header }} Logo" class="{{ jazzmin_settings.site_logo_classes }} brand-image" style="opacity: .8; margin: 0 0 0 5px;">
+                        </a>
+                    </li>
+                {% endif %}
+
+                {% get_top_menu user request.current_app|default:"admin" as top_menu %}
+                {% for link in top_menu %}
+                    <li class="nav-item d-none d-sm-inline-block{% if link.children %} dropdown{% endif %}">
+                        {% if link.children %}
+                            <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                {{ link.name }}
+                            </a>
+                            <div class="dropdown-menu">
+                                {% for child in link.children %}
+                                    <a class="dropdown-item" href="{{ child.url }}" {% if link.new_window %}target="_blank"{% endif %}>{{ child.name }}</a>
+                                {% endfor %}
+                            </div>
+                        {% else %}
+                            <a href="{{ link.url }}" class="nav-link" {% if link.new_window %}target="_blank"{% endif %}>{{ link.name }}</a>
+                        {% endif %}
+                    </li>
+                {% endfor %}
+            </ul>
+
+            {% if jazzmin_settings.search_model %}
+                {% for search_model in jazzmin_settings.search_models_parsed %}
+                    <form action="{{ search_model.search_url }}" method="GET" class="form-inline ml-3">
+                        <div class="input-group input-group-sm">
+                            <input class="form-control form-control-navbar" name="q" type="search" placeholder="{% trans 'Search' %} {{ search_model.search_name }}..." aria-label="{% trans 'Search' %} {{ search_model.search_name }}...">
+                            <div class="input-group-append">
+                                <button class="btn btn-navbar" type="submit">
+                                    <i class="fas fa-search"></i>
+                                </button>
+                            </div>
+                        </div>
+                    </form>
+                {% endfor %}
+            {% endif %}
+
+            <ul class="navbar-nav ml-auto">
+
+                {% if jazzmin_settings.show_ui_builder %}
+                <li class="nav-item">
+                    <a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#" role="button">
+                        <i class="fas fa-th-large"></i>
+                    </a>
+                </li>
+                {% endif %}
+                {% if 'django.contrib.admindocs'|app_is_installed %}
+                <li class="nav-item">
+                    <a class="nav-link" href="{% url 'django-admindocs-docroot' %}" role="button">
+                        <i class="fas fa-book"></i>
+                    </a>
+                </li>
+                {% endif %}
+
+                {% if jazzmin_settings.language_chooser %}
+                    {% get_available_languages as LANGUAGES %}
+                    {% get_language_info_list for LANGUAGES as languages %}
+
+                    <li class="nav-item dropdown">
+                        <a class="nav-link btn" data-toggle="dropdown" href="#" title="Choose language">
+                            <i class="fas fa-globe" aria-hidden="true"></i>
+                        </a>
+                        <div class="dropdown-menu dropdown-menu-lg dropdown-menu-left" id="jazzy-languagemenu">
+                            <form action="{% url 'set_language' %}" method="post">
+                                {% csrf_token %}
+                                <input name="next" type="hidden" value="{{ request.get_full_path|remove_lang:LANGUAGE_CODE }}" />
+                                {% for language in languages %}
+                                    <button
+                                        type="submit"
+                                        name="language"
+                                        value="{{ language.code }}"
+                                        class="dropdown-item {% if language.code == LANGUAGE_CODE %}active{% endif %}"
+                                        lang="{{ language.code }}"
+                                    >
+                                        {{ language.name_local|title }}
+                                    </button>
+                                {% endfor %}
+                            </form>
+                        </div>
+                    </li>
+                {% endif %}
+
+                <li class="nav-item dropdown">
+                    <a class="nav-link btn" data-toggle="dropdown" href="#" title="{{ request.user }}">
+                        <i class="far fa-user" aria-hidden="true"></i>
+                    </a>
+                    <div class="dropdown-menu dropdown-menu-lg dropdown-menu-left" id="jazzy-usermenu">
+                        <span class="dropdown-header">{% trans 'Account' %}</span>
+                        <div class="dropdown-divider"></div>
+                        <a href="{% url 'admin:password_change' %}" class="dropdown-item">
+                            <i class="fas fa-key mr-2"></i> {% trans 'Change password' %}
+                        </a>
+                        <div class="dropdown-divider"></div>
+                        <a href="{% url 'admin:logout' %}" class="dropdown-item">
+                            <i class="fas fa-users mr-2"></i> {% trans 'Log out' %}
+                        </a>
+                        {% get_user_menu user request.current_app|default:"admin" as user_menu %}
+                        {% for link in user_menu %}
+                            <div class="dropdown-divider"></div>
+                            <a href="{{ link.url }}" class="dropdown-item" {% if link.new_window %}target="_blank"{% endif %}>
+                                <i class="{{ link.icon }} mr-2"></i> {% trans link.name %}
+                            </a>
+                        {% endfor %}
+                        <div class="dropdown-divider"></div>
+                        {% if perms|can_view_self %}
+                            <a href="{% jazzy_admin_url request.user request.current_app|default:"admin" %}" class="dropdown-item dropdown-footer">{% trans 'See Profile' %}</a>
+                        {% endif %}
+                    </div>
+                </li>
+            </ul>
+        </nav>
+        {% block sidebar %}
+        {% if jazzmin_settings.show_sidebar %}
+            {% get_side_menu as side_menu_list %}
+
+            <aside class="main-sidebar elevation-4 {{ jazzmin_ui.sidebar_classes }}" id="jazzy-sidebar">
+                <a href="{% url 'admin:index' %}" class="brand-link {{ jazzmin_ui.brand_classes }}" id="jazzy-logo">
+                    <img src="{% static jazzmin_settings.site_logo %}" alt="{{ jazzmin_settings.site_header }} Logo" class="{{ jazzmin_settings.site_logo_classes }} brand-image elevation-3" style="opacity: .8">
+                    <span class="brand-text font-weight-light">{{ jazzmin_settings.site_brand }}</span>
+                </a>
+
+                <div class="sidebar">
+                    <div class="user-panel mt-3 pb-3 mb-3 d-flex">
+                        <div class="image">
+                            {% if jazzmin_settings|has_jazzmin_setting:"user_avatar" %}
+                                <img src="{% get_user_avatar request.user %}" width="160px" class="img-circle elevation-2" alt="User Image">
+                            {% else %}
+                                <i class="fas fa-inverse user-profile fa-user-circle"></i>
+                            {% endif %}
+                        </div>
+                        <div class="info">
+                            {% if perms|can_view_self %}
+                                <a href="{% jazzy_admin_url request.user request.current_app|default:"admin" %}" class="d-block">{{ request.user }}</a>
+                            {% else %}
+                                <span class="d-block" style="color: white;">{{ request.user }}</span>
+                            {% endif %}
+                        </div>
+                    </div>
+
+                    <nav class="mt-2">
+                        <ul class="nav nav-pills nav-sidebar flex-column {{ jazzmin_ui.sidebar_list_classes }}" data-widget="treeview" role="menu" data-collapsible="false">
+
+                            <li class="nav-item">
+                                <a href="{% url 'admin:index' %}" class="nav-link">
+                                    <i class="nav-icon fas fa-th-large"></i>
+                                    <p>{% trans 'Dashboard' %}</p>
+                                </a>
+                            </li>
+
+                            {% if jazzmin_settings.navigation_expanded %}
+                                {% for app in side_menu_list %}
+                                    <li class="nav-header">{{ app.name }}</li>
+                                    {% for model in app.models %}
+                                        <li class="nav-item">
+                                            {% if model.url %}
+                                            <a href="{{ model.url }}" class="nav-link">
+                                                <i class="nav-icon {{ model.icon }}"></i> <p>{{ model.name }}</p>
+                                            </a>
+                                        {% else %}
+                                            <span class="nav-link disabled">
+                                                <i class="nav-icon {{ model.icon }}"></i> <p>{{ model.name }}</p>
+                                            </span>
+                                        {% endif %}
+                                        </li>
+                                    {% endfor %}
+                                {% endfor %}
+                            {% else %}
+                                {% for app in side_menu_list %}
+                                    <li class="nav-item has-treeview">
+                                        <a href="#" class="nav-link">
+                                            <i class="nav-icon {{ app.icon }}"></i>
+                                            <p>{{ app.name|truncatechars:21 }} <i class="fas fa-angle-left right"></i></p>
+                                        </a>
+                                        <ul class="nav nav-treeview" style="display: none;">
+                                            {% for model in app.models %}
+                                                <li class="nav-item">
+                                                    <a href="{% if model.url %}{{ model.url }}{% else %}javascript:void(0){% endif %}" class="nav-link">
+                                                        <i class="nav-icon {{ model.icon }}"></i>
+                                                        <p>{{ model.name }}</p>
+                                                    </a>
+                                                </li>
+                                            {% endfor %}
+                                        </ul>
+                                    </li>
+                                {% endfor %}
+                            {% endif %}
+                        </ul>
+                    </nav>
+                </div>
+            </aside>
+        {% endif %}
+        {% endblock %}
+    {% endif %}
+
+    <div class="content-wrapper" {% if is_popup %}style="margin-left:0px; padding-top: 20px;"{% endif %}>
+        {% block page_content %}
+            {% if not is_popup %}
+            <div class="content border-bottom mb-2">
+                <div class="container-fluid">
+                    <div class="row">
+                        <div class="col-12 col-md-auto d-flex flex-grow-1 align-items-center">
+                            <h1 class="h4 m-0 pr-3 mr-3 border-right">{% block content_title %}{% endblock %}</h1>
+                            {% block breadcrumbs %}{% endblock %}
+                        </div>
+                        {% block page_actions %}{% endblock %}
+                    </div>
+                </div>
+            </div>
+            {% endif %}
+
+            <div class="content">
+                <div class="container-fluid">
+                    <section id="content" class="content">
+                        {% block messages %}
+                            {% for message in messages %}
+                                {% if message.tags == 'success' %}
+                                    <div class="alert alert-success alert-dismissible">
+                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×
+                                        </button>
+                                        <i class="icon fa fa-check"></i>{{ message|capfirst }}
+                                    </div>
+                                {% elif message.tags == 'error' %}
+                                    <div class="alert alert-danger alert-dismissible">
+                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×
+                                        </button>
+                                        <i class="icon fa fa-ban"></i>{{ message|capfirst }}
+                                    </div>
+                                {% elif message.tags == 'warning' %}
+                                    <div class="alert alert-warning alert-dismissible">
+                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×
+                                        </button>
+                                        <i class="icon fa fa-exclamation-triangle"></i>{{ message|capfirst }}
+                                    </div>
+                                {% elif message.tags == 'info' %}
+                                    <div class="alert alert-info alert-dismissible">
+                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×
+                                        </button>
+                                        <i class="icon fa fa-info"></i>{{ message|capfirst }}
+                                    </div>
+                                {% endif %}
+                            {% endfor %}
+                        {% endblock messages %}
+                        <div class="row">
+                          <div class="col-lg-9 col-12">
+                            <div class="row">
+                              <div class="col-md-6 col-sm-12">
+                                <div class="card text-center">
+                                  <div class="card-header">
+                                    <h5 class="m-0">Дополнительные настройки системы</h5>
+                                  </div>
+                                  <div class="card-body">
+                                    {% block site-settings %}{% endblock %}
+                                  </div>
+                                </div>
+                              </div>
+                            </div>
+                          </div>
+                          {% block content %} {% endblock %}
+                        </div>
+                    </section>
+                </div>
+            </div>
+        {% endblock %}
+    </div>
+
+{% block footer %}
+    {% if not is_popup %}
+        <footer class="main-footer {{ jazzmin_ui.footer_classes }}">
+            <div class="float-right d-none d-sm-inline">
+                <b>{% trans 'Jazzmin version' %}</b> {% get_jazzmin_version %}
+            </div>
+            {% autoescape off %}
+                <strong>{% trans 'Copyright' %} &copy; {% now 'Y' %} {{ jazzmin_settings.copyright }}.</strong> {% trans 'All rights reserved.' %}
+            {% endautoescape %}
+        </footer>
+        {% if jazzmin_settings.show_ui_builder %}
+            {% include 'jazzmin/includes/ui_builder_panel.html' %}
+        {% endif %}
+    {% endif %}
+{% endblock %}
+
+</div>
+
+{% if jazzmin_settings.show_ui_builder %}
+<div id="codeBox" class="modal fade" role="dialog">
+    <div class="modal-dialog">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h4 class="modal-title">{% trans 'UI Configuration' %}</h4>
+                <button type="button" class="close" data-dismiss="modal">&times;</button>
+            </div>
+            <div class="modal-body">
+                <p>{% trans 'Copy this info your settings file to persist these UI changes' %}</p>
+                <pre><code></code></pre>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn {{ jazzmin_ui.button_classes.danger }}" data-dismiss="modal">{% trans 'Close' %}</button>
+            </div>
+        </div>
+
+    </div>
+</div>
+{% endif %}
+
+<!-- jQuery -->
+<script src="{% static "admin/js/vendor/jquery/jquery.js" %}"></script>
+<!-- Bootstrap 4 -->
+<script src="{% static "vendor/bootstrap/js/bootstrap.min.js" %}"></script>
+<!-- AdminLTE App -->
+<script src="{% static "vendor/adminlte/js/adminlte.min.js" %}"></script>
+<!-- Django customisations -->
+<script src="{% static "jazzmin/js/main.js" %}"></script>
+
+{% if jazzmin_settings.custom_js %}
+<script src="{% static jazzmin_settings.custom_js %}"></script>
+{% endif %}
+
+{% if jazzmin_settings.show_ui_builder %}
+<script>
+    window.ui_changes = JSON.parse('{{ jazzmin_ui.raw|as_json|safe }}');
+</script>
+<script src="{% static "jazzmin/js/ui-builder.js" %}"></script>
+{% endif %}
+
+{% block extrajs %}{% endblock %}
+
+</body>
+</html>

+ 14 - 0
templates/admin/base_site.html

@@ -0,0 +1,14 @@
+{% extends "admin/base.html" %}
+
+{% load static %}
+
+{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}
+
+{% block extrahead %}
+		<link rel="shortcut icon" href="{% static 'sharix_admin/img/logo.png' %}" />
+{% endblock %}
+{% block site-settings %}
+<a class="btn btn-outline-info" href="{% url 'design:settings' %}">Загрузить логотип</a>
+<a class="btn btn-outline-info" href="{% url 'design:colors' %}">Настроить цвета</a>
+{% endblock %}
+

+ 49 - 0
templates/admin/change_colors.html

@@ -0,0 +1,49 @@
+{% extends 'admin/base_site.html' %}
+
+{% block title %}Настройка цвета{% endblock %}
+
+{% block content %}
+  <form method="POST" action="">
+    {% csrf_token %}
+    <div class="input-group mb-3">
+      <label for="{{form.btnBg.id_for_label}}">{{form.btnBg.label}}: </label>{{form.btnBg}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnTxt.id_for_label}}">{{form.btnTxt.label}}: </label>{{form.btnTxt}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnHover.id_for_label}}">{{form.btnHover.label}}: </label>{{form.btnHover}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.pillsBg.id_for_label}}">{{form.pillsBg.label}}: </label>{{form.pillsBg}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.pillspillsTxt.id_for_label}}">{{form.pillsTxt.label}}: </label>{{form.pillsTxt}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.linksTxt.id_for_label}}">{{form.linksTxt.label}}: </label>{{form.linksTxt}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.linksHover.id_for_label}}">{{form.linksHover.label}}: </label>{{form.linksHover}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnSuccessBg.id_for_label}}">{{form.btnSuccessBg.label}}: </label>{{form.btnSuccessBg}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnSuccessTxt.id_for_label}}">{{form.btnSuccessTxt.label}}: </label>{{form.btnSuccessTxt}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnSuccessHover.id_for_label}}">{{form.btnSuccessHover.label}}: </label>{{form.btnSuccessHover}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnDangerBg.id_for_label}}">{{form.btnDangerBg.label}}: </label>{{form.btnDangerBg}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnDangerTxt.id_for_label}}">{{form.btnDangerTxt.label}}: </label>{{form.btnDangerTxt}}
+    </div>
+    <div class="input-group mb-3">
+      <label for="{{form.btnDangerHover.id_for_label}}">{{form.btnDangerHover.label}}: </label>{{form.btnDangerHover}}
+    </div>
+    <button type="submit" class="btn btn-primary">Отправить</button>
+  </form>
+{% endblock %}

+ 20 - 0
templates/admin/upload_logo.html

@@ -0,0 +1,20 @@
+{% extends 'admin/base_site.html' %}
+
+{% block title %}Настройка системы{% endblock %}
+
+{% block content %}
+	<form method="POST" action="" enctype="multipart/form-data" style="width:50%;">
+		{% csrf_token %}
+		<div class="input-group mb-3">
+			<label for="{{form.namesystem.id_for_label}}">{{form.namesystem.label}}: </label>{{form.namesystem}}
+		</div>
+		<div class="input-group mb-3">
+			<div class="custom-file">
+				<label class="custom-file-label" for="{{form.logo.id_for_label}}">{{form.logo.label}}: </label>{{form.logo}}
+			</div>
+			<div class="input-group-append">
+				<button class="btn btn-primary">Upload</button>
+			</div>
+		</div>
+	</form>
+{% endblock %}

+ 84 - 0
templates/registration/base.html

@@ -0,0 +1,84 @@
+{% load i18n static jazzmin admin_urls %}
+{% get_current_language as LANGUAGE_CODE %}
+{% get_current_language_bidi as LANGUAGE_BIDI %}
+{% get_jazzmin_settings request as jazzmin_settings %}
+{% get_jazzmin_ui_tweaks as jazzmin_ui %}
+
+<!DOCTYPE html>
+<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+
+    <title>{% block title %}{{ title }} | {{ jazzmin_settings.site_title }}{% endblock %}</title>
+
+    <!-- Font Awesome Icons -->
+    <link rel="stylesheet" href="{% static "vendor/fontawesome-free/css/all.min.css" %}">
+
+    <!-- Bootstrap and adminLTE -->
+    <link rel="stylesheet" href="{% static "vendor/adminlte/css/adminlte.min.css" %}">
+
+    <!-- Bootswatch theme -->
+    {% if jazzmin_ui.theme.name != 'default' %}
+        <link rel="stylesheet" href="{{ jazzmin_ui.theme.src }}" id="jazzmin-theme" />
+    {% endif %}
+
+    {% if jazzmin_ui.dark_mode_theme %}
+        <link rel="stylesheet" href="{{ jazzmin_ui.dark_mode_theme.src }}" id="jazzmin-dark-mode-theme" media="(prefers-color-scheme: dark)"/>
+    {% endif %}
+
+    <!-- Custom fixes for django -->
+    <link rel="stylesheet" href="{% static "jazzmin/css/main.css" %}">
+
+    {% if jazzmin_settings.custom_css %}
+        <!-- Custom CSS -->
+        <link rel="stylesheet" href="{% static jazzmin_settings.custom_css %}">
+    {% endif %}
+
+    <!-- favicons -->
+    <link rel="shortcut icon" href="{% static jazzmin_settings.site_icon %}" type="image/png">
+    <link rel="icon" href="{% static jazzmin_settings.site_icon %}" sizes="32x32" type="image/png">
+
+    {% if jazzmin_settings.use_google_fonts_cdn %}
+    <!-- Google Font: Source Sans Pro -->
+    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
+    {% endif %}
+
+    {% block extrastyle %} {% endblock %}
+    {% block extrahead %} {% endblock %}
+</head>
+<body class="hold-transition jazzmin-login-page">
+
+<div class="login-box">
+    <div class="login-logo">
+        <h1>
+            <picture>
+                <source
+                    srcset="{% static jazzmin_settings.login_logo_dark %}"
+                    media="(prefers-color-scheme: dark)">
+                 <img style="height: 150px;" src="{% static jazzmin_settings.login_logo %}" alt="{{ jazzmin_settings.site_header }}">
+            </picture>
+        </h1>
+    </div>
+
+    <div class="card">
+        <div class="card-body">
+            {% block content %} {% endblock %}
+        </div>
+    </div>
+</div>
+
+<!-- jQuery -->
+<script src="{% static "admin/js/vendor/jquery/jquery.js" %}"></script>
+<!-- Bootstrap 4 -->
+<script src="{% static 'vendor/bootstrap/js/bootstrap.min.js' %}"></script>
+<!-- AdminLTE App -->
+<script src="{% static 'vendor/adminlte/js/adminlte.min.js' %}"></script>
+
+{% if jazzmin_settings.custom_js %}
+    <script src="{% static jazzmin_settings.custom_js %}"></script>
+{% endif %}
+
+</body>
+</html>

+ 12 - 0
urls.py

@@ -0,0 +1,12 @@
+from django.urls import path
+from design_template import views
+from django.shortcuts import redirect
+
+
+app_name = "design"
+
+urlpatterns = [
+    path("", views.upload, name="settings"),
+    path("logo.png", lambda _ : redirect('sharix_admin/img/logo.png', permanent=True)),
+    path("colors", views.change_colors, name="colors"),
+]

+ 5 - 0
utils.py

@@ -0,0 +1,5 @@
+def handle_uploaded_file(file): 
+    file.name = "logo."+file.name.split('.')[1]
+    with open('sharix_admin/static/sharix_admin/img/'+file.name, 'wb+') as destination: 
+        for chunk in file.chunks(): 
+            destination.write(chunk) 

+ 125 - 0
views.py

@@ -0,0 +1,125 @@
+from django.shortcuts import render
+from django.contrib import messages
+from django.http import HttpResponseRedirect
+from design_template.utils import handle_uploaded_file
+from design_template.forms import ColorsForm, LogoForm
+from core import settings
+
+import subprocess
+
+def upload(request):
+    if request.method == 'POST':
+        form = LogoForm(request.POST, request.FILES)
+        if form.is_valid():
+            settings.NAME_SYSTEM = request.POST.get('namesystem')
+            handle_uploaded_file(request.FILES.get('logo'))
+            form.save()
+            subprocess.run(
+                ["/root/sharix-open-webapp-base/bin/collectstatic.sh"])
+            messages.success(
+                request, "The logo has been uploaded successfully.")
+            return HttpResponseRedirect("/admin")
+    else:
+        form = LogoForm()
+    return render(request, "admin/upload_logo.html", {'form': form})
+
+
+def change_colors(request):
+    if request.method == 'POST':
+        form = ColorsForm(request.POST)
+        if form:
+            btnBg = request.POST.get('btnBg')
+            btnTxt = request.POST.get('btnTxt')
+            btnHover = request.POST.get('btnHover')
+            pillsBg = request.POST.get('pillsBg')
+            pillsTxt = request.POST.get('pillsTxt')
+            linksTxt = request.POST.get('linksTxt')
+            linksHover = request.POST.get('linksHover')
+            btnSuccessBg = request.POST.get('btnSuccessBg')
+            btnSuccessTxt = request.POST.get('btnSuccessTxt')
+            btnSuccessHover = request.POST.get('btnSuccessHover')
+            btnDangerBg = request.POST.get('btnDangerBg')
+            btnDangerTxt = request.POST.get('btnDangerTxt')
+            btnDangerHover = request.POST.get('btnDangerHover')
+
+            css = f'''
+:root{{
+  --btn-bg-color: {btnBg};
+  --btn-txt-color: {btnTxt};
+  --btn-hover-color: {btnHover};
+  --pills-bg-color: {pillsBg};
+  --pills-txt-color: {pillsTxt};
+  --links-txt-color: {linksTxt};
+  --links-hover-color: {linksHover};
+  --btn-success: {btnSuccessBg};
+  --btn-success-txt: {btnSuccessTxt};
+  --btn-success-hover: {btnSuccessHover};
+  --btn-danger: {btnDangerBg};
+  --btn-danger-txt: {btnDangerTxt};
+  --btn-danger-hover: {btnDangerHover};
+}}
+
+.btn-primary, .btn-outline-primary{{
+  background-color: var(--btn-bg-color);
+  color: var(--btn-txt-color);
+  border-color: var(--btn-bg-color);
+}}
+
+.btn-primary:hover, .btn-outline-primary:hover{{
+  background-color: var(--btn-hover-color);
+  border-color: var(--btn-hover-color);
+}}
+
+.nav-pills .nav-link.active, .nav-pills .show>.nav-link{{
+  background-color: var(--pills-bg-color);
+  color: var(--pills-txt-color);
+}}
+
+a{{
+ color: var(--links-txt-color); 
+}}
+
+a:hover{{
+  color:var(--links-hover-color)
+}}
+
+.nav-link{{
+  color: var(--links-txt-color)
+}}
+
+.nav-link:hover{{
+  color:var(--links-hover-color)
+}}
+
+.btn-success, .btn-outline-success{{
+  color: var(--btn-txt-color);
+  background-color: var(--btn-success);
+  border-color: var(--btn-success);
+}}
+
+.btn-success:hover, .btn-outline-success:hover{{
+  background-color: var(--btn-success-hover);
+  border-color: var(--btn-success-hover);
+}}
+
+.btn-danger, .btn-outline-danger{{
+  color: var(--btn-danger-txt);
+  background-color: var(--btn-danger);
+  border-color: var(--btn-danger);
+}}
+
+.btn-danger:hover, .btn-outline-danger:hover{{
+  background-color: var(--btn-danger-hover);
+  border-color: var(--btn-danger-hover);
+}}
+
+'''
+            with open("design_template/static/design_template/colors.css", 'r+', encoding='utf-8') as file:
+                file.write(css)
+            subprocess.run(
+                ["bin/collectstatic.sh"])
+            messages.success(request, "The colors changed successfully.")
+    else:
+        form = ColorsForm()
+    
+    return render(request, "admin/change_colors.html", {'form': form})