-
Notifications
You must be signed in to change notification settings - Fork 37
Web Api users creation #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Rub21
wants to merge
11
commits into
develop
Choose a base branch
from
web_users
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
30d1c4b
Add site to add users
eb2173b
Encode password method
00469ab
Forms for user creation
3a9ca5a
Update var name
af214bc
Update dashboard
8dfe6f9
Update container
21cdb3e
Add extra DB
3713462
Avoid to update password
8569d31
Add changeset count column
fb6cf2e
Update django app - container
06b0179
Dockerfile update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM python:3 | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
ENV PYTHONUNBUFFERED=1 | ||
RUN apt-get update \ | ||
&& apt-get install -y postgresql-client | ||
|
||
WORKDIR /app | ||
COPY app/requirements.txt /app/ | ||
RUN pip install -r requirements.txt | ||
RUN python -m pip install django[argon2] | ||
COPY app/ /app/ | ||
EXPOSE 8000/tcp | ||
CMD ./start.sh |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for dashboard 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', 'dashboard.settings') | ||
|
||
application = get_asgi_application() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
""" | ||
Django settings for dashboard project. | ||
|
||
Generated by 'django-admin startproject' using Django 3.2.16. | ||
|
||
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 | ||
import os | ||
# 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-acnap5f@i4v7^m2$ed0%i10ta%)1xza%k!zp-42%k*$tb6rt$%' | ||
|
||
# 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', | ||
'user' | ||
] | ||
|
||
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 = 'dashboard.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', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'dashboard.wsgi.application' | ||
|
||
|
||
# Database | ||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases | ||
|
||
DATABASES = { | ||
# 'default': { | ||
# 'ENGINE': 'django.db.backends.sqlite3', | ||
# 'NAME': BASE_DIR / 'db.sqlite3', | ||
# } | ||
'default': { | ||
'ENGINE': 'django.db.backends.postgresql', | ||
'NAME': os.environ.get('POSTGRES_DB'), | ||
'USER': os.environ.get('POSTGRES_USER'), | ||
'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), | ||
'HOST': os.environ.get('POSTGRES_HOST'), | ||
'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 = 'en-us' | ||
|
||
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' | ||
|
||
PASSWORD_HASHERS = [ | ||
'django.contrib.auth.hashers.Argon2PasswordHasher', | ||
'django.contrib.auth.hashers.PBKDF2PasswordHasher', | ||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', | ||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher', | ||
# 'django.contrib.auth.hashers.ScryptPasswordHasher', | ||
] | ||
|
||
# PASSWORD_HASHERS = [ | ||
# 'django.contrib.auth.hashers.PBKDF2PasswordHasher', | ||
# 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', | ||
# 'django.contrib.auth.hashers.Argon2PasswordHasher', | ||
# 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher', | ||
# ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""dashboard 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 | ||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for dashboard 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', 'dashboard.settings') | ||
|
||
application = get_wsgi_application() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', 'dashboard.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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Django>=3.0,<4.0 | ||
psycopg2>=2.8 | ||
argon2-cffi==21.3.0 | ||
django-scrypt==0.2.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -e | ||
export DEBUG=1 | ||
export SECRET_KEY=foo | ||
export DJANGO_ALLOWED_HOSTS="localhost 127.0.0.1 [::1]" | ||
export DJANGO_SUPERUSER_USERNAME=admin3 | ||
export DJANGO_SUPERUSER_PASSWORD=1234 | ||
export DJANGO_SUPERUSER_EMAIL="[email protected]" | ||
|
||
function startApp () { | ||
# python manage.py inspectdb > models.py | ||
python manage.py migrate | ||
python manage.py createsuperuser --no-input | ||
python manage.py runserver 0.0.0.0:8000 | ||
} | ||
|
||
flag=true | ||
while "$flag" = true; do | ||
pg_isready -h $POSTGRES_HOST -p 5432 >/dev/null 2>&2 || continue | ||
flag=false | ||
until $(curl -sf -o /dev/null $SERVER_URL); do | ||
echo "Waiting to start rails ports server..." | ||
sleep 2 | ||
done & startApp | ||
done |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.contrib import admin | ||
from .models import Users | ||
from .forms import UsersForm | ||
|
||
# Register your models here. | ||
class UserAdmin(admin.ModelAdmin): | ||
list_display = ("email", "id", "display_name", "status") | ||
form = UsersForm | ||
|
||
|
||
admin.site.register(Users, UserAdmin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class UserConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'user' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from .models import Users | ||
from django import forms | ||
|
||
FRUIT_CHOICES = [ | ||
("active", "Active"), | ||
("pending", "Pendig"), | ||
("confirmed", "Confirmed"), | ||
("suspended", "Suspended"), | ||
("deleted", "Deleted"), | ||
] | ||
|
||
|
||
class UsersForm(forms.ModelForm): | ||
email = forms.EmailField(help_text="Enter a valid email address.") | ||
pass_crypt = forms.CharField(label="Password", required=True) | ||
display_name = forms.CharField(label="User name", required=True) | ||
status = forms.CharField(label="Status", widget=forms.Select(choices=FRUIT_CHOICES)) | ||
|
||
class Meta: | ||
model = Users | ||
fields = ["email", "display_name", "pass_crypt", "status"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by Django 3.2.16 on 2022-10-04 23:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Users', | ||
fields=[ | ||
('email', models.CharField(max_length=100, unique=True)), | ||
('id', models.BigAutoField(primary_key=True, serialize=False)), | ||
('pass_crypt', models.CharField(max_length=100)), | ||
('creation_time', models.DateTimeField()), | ||
('display_name', models.CharField(max_length=100, unique=True)), | ||
('data_public', models.BooleanField()), | ||
('description', models.TextField()), | ||
('home_lat', models.FloatField(blank=True, null=True)), | ||
('home_lon', models.FloatField(blank=True, null=True)), | ||
('home_zoom', models.SmallIntegerField(blank=True, null=True)), | ||
('pass_salt', models.CharField(blank=True, max_length=100, null=True)), | ||
('email_valid', models.BooleanField()), | ||
('new_email', models.CharField(blank=True, max_length=100, null=True)), | ||
('creation_ip', models.CharField(blank=True, max_length=100, null=True)), | ||
('languages', models.CharField(blank=True, max_length=100, null=True)), | ||
('status', models.TextField()), | ||
('terms_agreed', models.DateTimeField(blank=True, null=True)), | ||
('consider_pd', models.BooleanField()), | ||
('auth_uid', models.CharField(blank=True, max_length=100, null=True)), | ||
('preferred_editor', models.CharField(blank=True, max_length=100, null=True)), | ||
('terms_seen', models.BooleanField()), | ||
('description_format', models.TextField()), | ||
('changesets_count', models.IntegerField()), | ||
('traces_count', models.IntegerField()), | ||
('diary_entries_count', models.IntegerField()), | ||
('image_use_gravatar', models.BooleanField()), | ||
('auth_provider', models.CharField(blank=True, max_length=100, null=True)), | ||
('home_tile', models.BigIntegerField(blank=True, null=True)), | ||
('tou_agreed', models.DateTimeField(blank=True, null=True)), | ||
], | ||
options={ | ||
'db_table': 'users', | ||
'managed': False, | ||
}, | ||
), | ||
] |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.