Skip to content

Commit

Permalink
adicionado os arquivos do projeto
Browse files Browse the repository at this point in the history
  • Loading branch information
alexiusstrauss committed Aug 9, 2021
1 parent 27f74b3 commit 1ed5dc0
Show file tree
Hide file tree
Showing 7,217 changed files with 833,666 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .coverage
Binary file not shown.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
omit =
*migrations*,
*desafio*,
*tests*,
pytransfer*
conftest.py
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.8

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /code

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .



Empty file added dessafio/__init__.py
Empty file.
Binary file added dessafio/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added dessafio/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file added dessafio/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added dessafio/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions dessafio/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for dessafio project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dessafio.settings')

application = get_asgi_application()
148 changes: 148 additions & 0 deletions dessafio/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
"""
Django settings for dessafio project.
Generated by 'django-admin startproject' using Django 3.2.6.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-hyd^8!u9jitxhda1dox-tki=+okhrrxep0n-8g@xg%w9o6e#x1'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

DEFAULT_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

THIRD_PARTY_APPS = [
'rest_framework',
'rest_framework_swagger',
]

LOCAL_APPS = [
'pytransfer.apps.PytransferConfig',
]

INSTALLED_APPS = DEFAULT_APPS + THIRD_PARTY_APPS + LOCAL_APPS

REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' }


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 = 'dessafio.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
'libraries' : {
'staticfiles': 'django.templatetags.static',
}
},
},
]

WSGI_APPLICATION = 'dessafio.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
'default': {

'ENGINE': 'django.db.backends.postgresql',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'db',
'PORT': 5432,

}
}


# Password validation
# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/

LANGUAGE_CODE = 'pt-BR'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'


# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
30 changes: 30 additions & 0 deletions dessafio/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""dessafio URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/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, include
from pytransfer import urls as ApiUrl
from django.views.generic import TemplateView
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='pyTransfer')


urlpatterns = [
path('', schema_view, name='swagger-ui' ),
path('admin/', admin.site.urls),
path('api/', include(ApiUrl)),

]
16 changes: 16 additions & 0 deletions dessafio/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for dessafio 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/3.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dessafio.settings')

application = get_wsgi_application()
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "3.8"

services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- 8000:8000
depends_on:
- db
db:
image: postgres:13
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- postgres_data:/var/lib/postgresql/data/

volumes:
postgres_data:
22 changes: 22 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dessafio.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)


if __name__ == '__main__':
main()
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = dessafio.settings
Empty file added pytransfer/__init__.py
Empty file.
9 changes: 9 additions & 0 deletions pytransfer/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.contrib import admin
from .models import Pessoa, Token, Balance, History


admin.site.register(Pessoa)
admin.site.register(Token)
admin.site.register(Balance)
admin.site.register(History)

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


class PytransferConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'pytransfer'
26 changes: 26 additions & 0 deletions pytransfer/funcoes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Funcoes

import hashlib
from random import choice, getrandbits


def genBalanceRandom():
#Funcao para gerar Saldo randomico - possivel de implementações e regras.
result = getrandbits(16)
return result


def randomchar(tamanho):
# funcao para dandomizar um char de tamanho definido
caracteres = '123456-78ABCDEFGHJK-MNPQRSTXabcdefghjkmnpqrstxz-'
result = ''
for char in range(tamanho):
result += choice(caracteres)
return result

def getnewtoken():
# funcao para criar token no padrao sha1 usando 2 valores randomicos
result = hashlib.sha1((randomchar(5) + randomchar(5)).encode('utf-8')).hexdigest()
return result

23 changes: 23 additions & 0 deletions pytransfer/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.6 on 2021-08-05 09:32

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Todo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.CharField(max_length=50)),
('done', models.BooleanField(default=False)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
]
28 changes: 28 additions & 0 deletions pytransfer/migrations/0002_pessoa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.6 on 2021-08-05 09:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('pytransfer', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Pessoa',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.CharField(max_length=50)),
('sobreNome', models.CharField(max_length=50)),
('nomeCompleto', models.CharField(max_length=110)),
('email', models.EmailField(max_length=254)),
('telefone', models.CharField(max_length=20)),
('cpf', models.CharField(max_length=20)),
('token', models.CharField(max_length=20)),
('ativo', models.BooleanField(default=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
]
Loading

0 comments on commit 1ed5dc0

Please sign in to comment.