1
0

Initial Commit

This commit is contained in:
2017-12-31 03:40:56 +03:00
commit 4dbb509588
18 changed files with 343 additions and 0 deletions

60
.gitignore vendored Normal file
View File

@@ -0,0 +1,60 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# OSX Finder turds
.DS_Store
# C extensions
*.so
# Distribution / packaging
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Rope
.ropeproject
# Django stuff:
*.log
*.pot
# Sphinx documentation
docs/_build/
.idea/
db.sqlite3
migrations/*
!migrations/__init__.py
venv/

0
app/__init__.py Normal file
View File

3
app/admin.py Normal file
View File

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

5
app/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class AppConfig(AppConfig):
name = 'app'

View File

9
app/models.py Normal file
View File

@@ -0,0 +1,9 @@
from django.db import models
# Create your models here.
class Setting(models.Model):
name = models.CharField(max_length=100)
language = models.CharField(max_length=5)
string = models.TextField()

11
app/settings_db.py Normal file
View File

@@ -0,0 +1,11 @@
from django.core.exceptions import ObjectDoesNotExist
from app.models import Setting
from django.conf import settings
def get_setting(name, language=settings.LANGUAGE_CODE):
# TODO: This function
try:
return Setting.objects.filter(name=name)[0].get().string
except ObjectDoesNotExist:
return 'Oops, setting {0} not found!'.format(name)

3
app/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

14
app/views.py Normal file
View File

@@ -0,0 +1,14 @@
from django.shortcuts import render
from django.utils.translation import gettext as _
from django.conf import settings
# Create your views here.
def home(request):
return render(request, 'home.html', {
'title': _('Home'),
'app_name': settings.APP_NAME,
'app_description_text': get_setting('app_description_text'),
})

15
manage.py Normal file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "noniko.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

0
noniko/__init__.py Normal file
View File

133
noniko/settings.py Normal file
View File

@@ -0,0 +1,133 @@
"""
Django settings for noniko project.
Generated by 'django-admin startproject' using Django 2.0.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'j)v9-q0lja+75hdmzi@^fyprfbkh_qcga45(=l*=4wew8kfgp)'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app.apps.AppConfig',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'noniko.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'noniko.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
APP_NAME = 'NoNiko'
try:
from local_settings import *
except ImportError:
pass

23
noniko/urls.py Normal file
View File

@@ -0,0 +1,23 @@
"""noniko URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
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.urls import path
import app.views
urlpatterns = [
path('', app.views.home, name='home'),
path('admin/', admin.site.urls),
]

16
noniko/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for noniko project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "noniko.settings")
application = get_wsgi_application()

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
django >=2, <3

4
static/style.css Normal file
View File

@@ -0,0 +1,4 @@
body {
min-height: 75rem;
padding-top: 4.5rem;
}

10
templates/home.html Normal file
View File

@@ -0,0 +1,10 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block body %}
<div class="jumbotron">
<h1>{% blocktrans %}Welcome to {{ app_name }} official site!{% endblocktrans %}</h1>
<p class="lead">
{{ app_text }}
</p>
</div>
{% endblock %}

36
templates/layout.html Normal file
View File

@@ -0,0 +1,36 @@
<!DOCTYPE html>
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<html lang="{{ LANGUAGE_CODE }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="{{ description }}" />
<meta name="keywords" content="{{ keywords }}" />
<title>{{ app_name }} - {{ title }}</title>
{% load staticfiles %}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<link href="{% static "style.css" %}" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="{% url "home" %}">{{ app_name }}</a>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="{% url "home" %}">{% trans "Home" %}</a>
</li>
</ul>
</div>
</nav>
<main role="main" class="controller">
{% block body %}
{% endblock %}
</main>
</body>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
{% block scripts %}
{% endblock %}
</html>