Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kaniak274 committed Oct 26, 2019
0 parents commit f2999e8
Show file tree
Hide file tree
Showing 40 changed files with 7,674 additions and 0 deletions.
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Database
pai_example.db

local/

# JavaScript
node_modules/
manifest-local.json

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# visual studio code settings
.vscode/

*.swp

db.py
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2019 Kaniak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Ebiznes

## INSTALLATION

### Prerequisites
```
Python 3.6
Node 10 or nvm(https://github.com/coreybutler/nvm-windows) with installed node 10
```

### VIRTUALENV
```
virtualenv env --python=python3
source env/bin/activate
pip install -r requirements/base.txt
```

### MIGRATIONS
Create database first and then
copy db.base.py into db.py and populate it with your settings and then run:

```
python manage.py migrate
```

### JAVASCRIPT
```
npm install
npm run build / npm run watch
```

### Run local server
```
python manage.py runserver
```

Then go to localhost:8000 in your browser.

### Admin
First create admin account with
```
python manage.py createsuperuser
```

Then go to localhost:8000/admin and login with created account.
Empty file added ebiznes/__init__.py
Empty file.
Empty file added ebiznes/apps/__init__.py
Empty file.
Empty file added ebiznes/apps/common/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions ebiznes/apps/common/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CommonConfig(AppConfig):
name = 'common'
Empty file.
50 changes: 50 additions & 0 deletions ebiznes/apps/common/templatetags/render_assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from django import template
from django.utils.safestring import mark_safe

from ..utils import get_static_url

register = template.Library()


@register.simple_tag
def render_js(resource_path):
"""Gets full url for javascript file with HTML tag.
Args:
resource_path - Path to javascript file in webserver without extension
Returns:
HTML tag with full url to javascript file.
"""
url = get_static_url(resource_path, extension='js')

if url:
return mark_safe('<script type="text/javascript" src="{}"></script>'.format(url))
else:
return ''


@register.simple_tag
def render_css(resource_path):
"""Gets full url for css file with HTML tag.
Args:
resource_path - Path to css file in webserver without extension
Returns:
HTML tag with full url to css file.
"""
url = get_static_url(resource_path, extension='css')

if url:
return mark_safe('<link rel="stylesheet" href="{}">'.format(url))
else:
return ''


@register.simple_tag
def static_image(resource_path):
"""Gets full path to image file wih HTML tag.
Args:
resource_path - Path to image in webserver without extension.
Returns:
HTML tag with full url to image file.
"""
return get_static_url(resource_path)

72 changes: 72 additions & 0 deletions ebiznes/apps/common/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import json
import os

from django.conf import settings
from django.templatetags.static import static


_manifest_contents = None


class NoManifestFileException(FileNotFoundError):
pass


class NoManifestSetting(KeyError):
pass


def get_static_url(resource_path, extension=None):
"""Gets static url to resource file.
Returns:
Static url to filename or None when filename was'nt in manifest file.
"""
data = _read_manifest_file()

if extension:
filename = data.get(
'{}.{}'.format(resource_path, extension), None)
else:
filename = data.get(resource_path, None)

if not filename:
return None
else:
return static(filename)


def _read_manifest_file():
"""Reads manifest file.
Returns:
If no exception returns json data with filenames and their static paths.
Raises:
NoManifestFileException: When no manifest file at path in WEBPACK_MANIFEST_FILE setting.
ValueError: When file does not contain valid json data.
IOError: When error while reading file.
"""
global _manifest_contents

if not settings.DEBUG and _manifest_contents:
return _manifest_contents

if settings.WEBPACK_MANIFEST_FILE:
path = os.path.normpath(settings.WEBPACK_MANIFEST_FILE)
else:
error_string = """
You have to spcify manifest file generated by
webpack-assets-manifest plugin in your settings like this:
WEBPACK_MANIFEST_FILE = os.path.join(BASE_DIR, 'example.json')
"""
raise NoManifestSetting(error_string)

try:
with open(path) as file:
_manifest_contents = json.loads(file.read())
return _manifest_contents
except FileNotFoundError as e:
return {}
except json.JSONDecodeError as e:
raise ValueError('Manifest file do not contains valid json data.') from e
except IOError as e:
raise IOError('Error while reading manifest file.') from e

Empty file added ebiznes/apps/users/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions ebiznes/apps/users/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import User


admin.site.register(User, UserAdmin)

5 changes: 5 additions & 0 deletions ebiznes/apps/users/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class UsersConfig(AppConfig):
name = 'users'
44 changes: 44 additions & 0 deletions ebiznes/apps/users/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Generated by Django 2.2.5 on 2019-09-16 16:17

import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
('auth', '0011_update_proxy_permissions'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
Empty file.
7 changes: 7 additions & 0 deletions ebiznes/apps/users/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib.auth.models import AbstractUser
from django.db import models


class User(AbstractUser):
pass

14 changes: 14 additions & 0 deletions ebiznes/assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Vue from 'vue';
import Toastr from 'vue-toastr';

import App from './components/App.vue';
import router from './router.js';

Vue.use(Toastr)

var app = new Vue({
el: '#app',
router,
render: h => h(App)
});

Empty file.
Loading

0 comments on commit f2999e8

Please sign in to comment.