Browse Source

changelog of installation

Roberto Berto 5 years ago
parent
commit
1c14df1492

+ 1 - 0
README.md

@@ -26,6 +26,7 @@ It will work with a single VyoS server or to multiple VyOS servers, so datacente
 * associate users to groups - admin only todo
 * associate groups to vyos servers - admin only todo
 * allow commum users to add vyos servers?
+* start page to create initial superadmin user on new installations - done
 
 ### interfaces module
 * list interfaces - alpha

+ 1 - 1
vycenter/accounts/templates/registration/logged_out.html

@@ -1,4 +1,4 @@
-{% extends "base.html" %}
+{% extends "base_not_logged.html" %}
 
 {% block header_title %}Logged out{% endblock %}
 {% block section_title %}Logged out{% endblock %}

+ 1 - 1
vycenter/accounts/templates/registration/login.html

@@ -1,4 +1,4 @@
-{% extends "base.html" %}
+{% extends "base_not_logged.html" %}
 
 {% block header_title %}Login{% endblock %}
 {% block section_title %}Login{% endblock %}

+ 5 - 1
vycenter/accounts/urls.py

@@ -15,8 +15,12 @@ from . import views
 app_name = 'accounts'
 
 
+
+
+
+
 urlpatterns = [
-   path('logout', views.logout, name='accounts-logout'),
+   path('', views.index, name='accounts-index'),
    # path('', include('django.contrib.auth.urls', name='vauth-login')
 ]
 

+ 28 - 0
vycenter/accounts/views.py

@@ -4,7 +4,35 @@ from django.template import loader
 from django.shortcuts import redirect
 from django.contrib.auth import authenticate
 from django.views.generic.base import TemplateView
+from django.conf import settings
 
 
+from django.contrib.auth.models import User
+
 import vyos
 
+
+
+
+def index(request):
+    if not request.user.is_authenticated:
+
+        users_admin = User.objects.filter(
+            is_active=True,
+            is_superuser=True
+        )
+
+        if users_admin.count() == 0:
+            if 'username' in request.POST and 'password' in request.POST:
+                user = User.objects.create_superuser(username=request.POST['username'], password=request.POST['password'])
+                user.save()
+                return redirect('registration-login')
+        else:
+            return redirect('registration-login')
+
+ 
+    template = loader.get_template('registration/start.html')
+    context = { 
+        'users_admin': users_admin.all()
+    }   
+    return HttpResponse(template.render(context, request))

+ 7 - 3
vycenter/vycenter/settings.py

@@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/3.0/topics/settings/
 For the full list of settings and their values, see
 https://docs.djangoproject.com/en/3.0/ref/settings/
 """
-
+import pathlib
 import os
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@@ -25,7 +25,8 @@ SECRET_KEY = '*wv2=o(o5$i2qim7yxras_7jf%n!*1rrzehv3o2f-ebsr@ba%4'
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG = True
 
-ALLOWED_HOSTS = []
+# put all your hosts here
+ALLOWED_HOSTS = ['127.0.0.1']
 
 
 # Application definition
@@ -159,5 +160,8 @@ USE_TZ = True
 
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/3.0/howto/static-files/
-
+STATIC_ROOT =  ''
+STATICFILES_DIRS = [
+    BASE_DIR + '/s/'
+]
 STATIC_URL = '/s/'

+ 2 - 109
vycenter/vycenter/templates/base.html

@@ -1,3 +1,4 @@
+{% load static %}
 <!doctype html>
 <html lang="en">
   <head>
@@ -7,117 +8,9 @@
 
     <!-- Bootstrap CSS -->
     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
+    <link rel="stylesheet" href="{% static "main.css" %}">
 
     <title>{% block header_title %}{% endblock %} - VyControl</title>
-
-    <style>
-    body {
-        background-color: #333;
-        color: white;
-        
-        
-    }
-
-    .container {
-        color: black;
-    }
-    .menu { 
-        background-color: #ccc;
-        padding: 5px;
-    }
-   
-    .menu a, .menu h2 { 
-      color: #000;
-    }    
-    .content { 
-        background-color: rgb(120, 120, 120);
-        padding: 0 10px 0 10px;
-    }
-    .content a {
-      color: #640000;
-    }
-    #menu-logotop h1 {
-      font-size: 10px;      
-    }
-    #menu-logotop {
-      background-color: #333;
-      padding: 0 0px 4px 0px;
-    }
-
-    #menu-logotop a {
-      color: #af1d1d;
-    }
-
-    #menu-topline {
-      padding-top: 3px;
-      background-color: #e14342;
-      margin-bottom: 2px;
-    }
-    #menu-logotop h2 {
-      font-size: 12px;
-    }
-    ol {
-      font-size: 11px;
-    }
-    p.menu-config {
-      padding: 0 5px;
-      margin: 0;
-    }
-    form.instancedefault {
-      display: inline;
-    }
-
-    #vyos-id,  #vycenter-config-menu {
-        margin-right: 10px;
-    }
-    
-    #debug {
-        background-color: #AB425E;
-        margin-top: 20px;
-        margin-bottom: 20px;
-    }
-    #debug h3 {
-        font-size: 14px;
-        padding-top: 10px;
-        padding-bottom: 10px;
-        margin: 0;
-    }  
-    #debug pre {
-      font-size: 12px;
-      padding-top: 0;   
-      margin: 0;  
-    }
-
-    #central h1 {
-      font-size: 18px;
-    }
-
-    #central h2 {
-      margin-top: 20px;
-      font-size: 14px;
-    }
-
-    #central {
-      font-size: 12px;
-    }
-    
-    #rulenumber:disabled {
-        background-color: #ddd;
-    }
-
-    #submit-firewall {
-      margin-top: 20px;
-    }
-
-    input[type=submit] {
-      background-color: #EACD65;
-      border: 0;
-    }
-
-    .separe-form {
-      margin-top: 30px;      
-    }
-    </style>
   </head>
   <body >
 

+ 12 - 4
vycenter/vycenter/urls.py

@@ -15,19 +15,24 @@ Including another URLconf
 """
 from django.contrib import admin
 from django.urls import include, path
-from django.views.generic import RedirectView
+from django.conf import settings
+
+def reload_urlconf(self):
+    if settings.ROOT_URLCONF in sys.modules:
+        reload(sys.modules[settings.ROOT_URLCONF])
+    return import_module(settings.ROOT_URLCONF)
+
+import pprint
 
 from . import views
 
 from django.contrib.auth import views as auth_views
 
 
-
 app_name = 'vycenter'
 
 urlpatterns = [
-    path('', RedirectView.as_view(url='/login/')),
-    #path('vauth/', include('vauth.urls')),
+    path('', include('accounts.urls')),
     path('config/', include('config.urls')),
     path('dashboard/', include('dashboard.urls')),
     #path('', views.vycenter_login, name='vycenter-login'),
@@ -53,3 +58,6 @@ urlpatterns = [
     path('ssh/', include('ssh.urls')),
     path('wanlb/', include('wanlb.urls')),
 ]
+
+
+