forked from Unicaronas/Unicaronas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
93 changed files
with
2,065 additions
and
549 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,5 +1,31 @@ | ||
from django.contrib import admin | ||
from .models import Application | ||
# Register your models here. | ||
|
||
# admin.site.register(Application) | ||
|
||
class ApplicationAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
'id', | ||
'client_id', | ||
'user', | ||
'redirect_uris', | ||
'client_secret', | ||
'skip_authorization', | ||
'created', | ||
'updated', | ||
'name', | ||
'description', | ||
'client_type', | ||
'authorization_grant_type', | ||
'platform', | ||
'scope', | ||
'website', | ||
'published', | ||
'logo', | ||
) | ||
list_filter = ( | ||
'user', | ||
'skip_authorization', | ||
'created', | ||
'updated', | ||
'published', | ||
) | ||
search_fields = ('name',) |
This file contains 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,47 @@ | ||
# Generated by Django 2.1.1 on 2018-10-01 07:06 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import oauth2_provider.generators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
replaces = [('oauth', '0001_initial'), ('oauth', '0002_auto_20171218_2330'), ('oauth', '0003_auto_20180703_0419'), ('oauth', '0004_auto_20180703_0428'), ('oauth', '0005_remove_application_application_id'), ('oauth', '0006_auto_20180914_1959'), ('oauth', '0007_auto_20180914_2000'), ('oauth', '0008_application_logo'), ('oauth', '0009_auto_20180922_1905')] | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Application', | ||
fields=[ | ||
('id', models.BigAutoField(primary_key=True, serialize=False)), | ||
('client_id', models.CharField(db_index=True, default=oauth2_provider.generators.generate_client_id, max_length=100, unique=True)), | ||
('redirect_uris', models.TextField(blank=True, help_text='Allowed URIs list, space separated')), | ||
('client_type', models.CharField(choices=[('confidential', 'Confidential'), ('public', 'Public')], default='confidential', max_length=32)), | ||
('authorization_grant_type', models.CharField(choices=[('authorization-code', 'Authorization code'), ('implicit', 'Implicit')], default='authorization-code', max_length=32)), | ||
('client_secret', models.CharField(blank=True, db_index=True, default=oauth2_provider.generators.generate_client_secret, max_length=255)), | ||
('name', models.CharField(max_length=255)), | ||
('skip_authorization', models.BooleanField(default=False)), | ||
('created', models.DateTimeField(auto_now_add=True)), | ||
('updated', models.DateTimeField(auto_now=True)), | ||
('scope', models.TextField(blank=True, help_text='Requested scopes, space separated')), | ||
('platform', models.CharField(choices=[('android', 'Android'), ('ios', 'iOS'), ('web', 'Website'), ('facebook', 'Facebook'), ('telegram', 'Telegram'), ('whatsapp', 'WhatsApp'), ('windows', 'Windows'), ('mac', 'MacOS'), ('linux', 'Linux')], default='web', max_length=50)), | ||
('description', models.TextField()), | ||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='oauth_application', to=settings.AUTH_USER_MODEL)), | ||
('published', models.BooleanField(default=False, help_text='Whether or not your app is published')), | ||
('website', models.URLField(blank=True, help_text="App's website or download page")), | ||
('logo', models.URLField(blank=True)), | ||
], | ||
options={ | ||
'abstract': False, | ||
'swappable': 'OAUTH2_PROVIDER_APPLICATION_MODEL', | ||
'ordering': ['-id'], | ||
}, | ||
), | ||
] |
This file contains 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 |
---|---|---|
|
@@ -50,24 +50,31 @@ | |
# Criando aplicativos | ||
""", | ||
terms_of_service="https://www.google.com/policies/terms/", | ||
contact=openapi.Contact(email="[email protected]"), | ||
license=openapi.License(name="BSD License"), | ||
terms_of_service="https://unicaronas.com/terms_and_conditions/", | ||
contact=openapi.Contact(name="Suporte", email="[email protected]", url="https://unicaronas.com"), | ||
license=openapi.License(name="AGPL3", url="https://opensource.org/licenses/AGPL-3.0"), | ||
x_logo={ | ||
"url": "/static/project/img/social/og-image.jpg", | ||
"backgroundColor": "#FFFFFF" | ||
} | ||
), | ||
# validators=['flex', 'ssv'], | ||
public=True, | ||
permission_classes=(permissions.AllowAny,), | ||
patterns=[path('api/', include(api_urls))], | ||
generator_class=TaggedDescriptionSchemaGenerator, | ||
generator_class=TaggedDescriptionSchemaGenerator | ||
) | ||
|
||
app_name = 'docs' | ||
|
||
|
||
docs_urlpatterns = [ | ||
path('swagger<str:format>', schema_view.without_ui(cache_timeout=0), name='schema-json'), | ||
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), | ||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), | ||
path('swagger<str:format>', schema_view.without_ui( | ||
cache_timeout=0), name='schema-json'), | ||
path('swagger/', schema_view.with_ui('swagger', | ||
cache_timeout=0), name='schema-swagger-ui'), | ||
path('redoc/', schema_view.with_ui('redoc', | ||
cache_timeout=0), name='schema-redoc'), | ||
] | ||
|
||
|
||
|
This file contains 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 |
---|---|---|
|
@@ -13,6 +13,9 @@ | |
import os | ||
import dj_database_url | ||
|
||
import sentry_sdk | ||
from sentry_sdk.integrations.django import DjangoIntegration | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | ||
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | ||
|
@@ -36,6 +39,14 @@ | |
|
||
ALLOWED_HOSTS = eval(os.environ.get('ALLOWED_HOSTS', '["*"]')) | ||
|
||
# Sentry | ||
|
||
if not DEBUG: | ||
sentry_sdk.init( | ||
dsn="https://[email protected]/1292000", | ||
integrations=[DjangoIntegration()] | ||
) | ||
|
||
|
||
# Application definition | ||
|
||
|
@@ -72,11 +83,19 @@ | |
'django_extensions', | ||
|
||
'captcha', | ||
'analytical', | ||
|
||
'drf_yasg', | ||
'silk', | ||
'nplusone.ext.django', | ||
'djcelery_email', | ||
'phonenumber_field', | ||
'watchman', | ||
] | ||
|
||
MIDDLEWARE = [ | ||
'silk.middleware.SilkyMiddleware', | ||
'nplusone.ext.django.NPlusOneMiddleware', | ||
'django.middleware.security.SecurityMiddleware', | ||
'whitenoise.middleware.WhiteNoiseMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
|
@@ -211,6 +230,8 @@ | |
|
||
ADMINS = [('Admin', os.environ.get('ADMIN_ACCOUNT')), ] | ||
|
||
EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' | ||
|
||
|
||
# Debug Toolbar | ||
SHOW_TOOLBAR_CALLBACK = eval(os.environ.get('SHOW_TOOLBAR_CALLBACK', 'True')) | ||
|
@@ -286,7 +307,7 @@ | |
ACCOUNT_SESSION_REMEMBER = True | ||
ACCOUNT_CONFIRM_EMAIL_ON_GET = True | ||
ACCOUNT_EMAIL_REQUIRED = True | ||
ACCOUNT_EMAIL_VERIFICATION = "mandatory" | ||
ACCOUNT_EMAIL_VERIFICATION = "none" | ||
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "http" | ||
ACCOUNT_FORMS = { | ||
'signup': 'user_data.forms.CustomSignupForm', | ||
|
@@ -335,5 +356,41 @@ def ACCOUNT_USER_DISPLAY(user): | |
} | ||
|
||
|
||
# Phonenumbers | ||
PHONENUMBER_DB_FORMAT = 'NATIONAL' | ||
PHONENUMBER_DEFAULT_REGION = 'BR' | ||
|
||
# Geocoding API | ||
GEOCODING_API_KEY = os.environ.get('GEOCODING_API_KEY') | ||
|
||
# Analytics | ||
GOOGLE_ANALYTICS_PROPERTY_ID = os.environ.get('GOOGLE_ANALYTICS_PROPERTY_ID') | ||
|
||
|
||
# Profiling | ||
SILKY_PYTHON_PROFILER = True | ||
SILKY_AUTHENTICATION = True | ||
SILKY_AUTHORISATION = True | ||
SILKY_PERMISSIONS = lambda user: user.is_superuser | ||
SILKY_META = True | ||
SILKY_MAX_RECORDED_REQUESTS = 10**3 | ||
|
||
|
||
# Watchman | ||
WATCHMAN_CHECKS = ( | ||
'project.status_checks.redis_check', | ||
'project.status_checks.celery_check', | ||
'project.status_checks.google_apis', | ||
'project.status_checks.facebook', | ||
'project.status_checks.blablacar', | ||
'project.status_checks.email', | ||
'watchman.checks.databases', | ||
'watchman.checks.caches', | ||
'watchman.checks.storage', | ||
) | ||
WATCHMAN_ENABLE_PAID_CHECKS = not DEBUG | ||
|
||
|
||
# Configure Django App for Heroku. | ||
import django_heroku | ||
# django_heroku.settings(locals()) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<browserconfig> | ||
<msapplication> | ||
<tile> | ||
<square150x150logo src="project/img/favicons/mstile-150x150.png"/> | ||
<TileColor>#b91d47</TileColor> | ||
</tile> | ||
</msapplication> | ||
</browserconfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,20 @@ | ||
{ | ||
"name": "Unicaronas", | ||
"short_name": "Unicaronas", | ||
"icons": [ | ||
{ | ||
"src": "android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"theme_color": "#ffffff", | ||
"background_color": "#ffffff", | ||
"start_url": "https://unicaronas.com", | ||
"display": "standalone" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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,5 @@ | ||
from .celery import celery_check | ||
from .redis import redis_check | ||
from .google_apis import google_apis | ||
from .third_party import facebook, blablacar | ||
from .email import email |
This file contains 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,18 @@ | ||
from celery.task.control import inspect | ||
from watchman.decorators import check | ||
|
||
|
||
@check | ||
def celery_worker_check(): | ||
try: | ||
insp = inspect() | ||
d = insp.stats() | ||
if not d: | ||
raise Exception('No running celery workers were found') | ||
except Exception as e: | ||
return {'worker': {'ok': False}} | ||
return {'worker': {'ok': True}} | ||
|
||
|
||
def celery_check(): | ||
return {'celery': [celery_worker_check()]} |
This file contains 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,24 @@ | ||
from django.core.mail import EmailMessage, get_connection | ||
from django.core.mail.backends.smtp import EmailBackend | ||
from django.conf import settings | ||
from watchman.decorators import check | ||
|
||
|
||
# @check | ||
def _check_email(): | ||
conn = get_connection(backend='django.core.mail.backends.smtp.EmailBackend') | ||
headers = {"X-DJANGO-WATCHMAN": True} | ||
email = EmailMessage( | ||
"django-watchman email check", | ||
"This is an automated test of the email system.", | ||
headers=headers, | ||
connection=conn | ||
) | ||
email.send() | ||
return {"ok": True} | ||
|
||
|
||
def email(): | ||
if not settings.WATCHMAN_ENABLE_PAID_CHECKS: | ||
return {} | ||
return {'Email': _check_email()} |
This file contains 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,15 @@ | ||
from django.conf import settings | ||
from search.geocoding import geocode_address | ||
from watchman.decorators import check | ||
|
||
|
||
@check | ||
def _geocode_address(): | ||
geocode_address('Unicamp') | ||
return {'Geocoding': {'ok': True}} | ||
|
||
|
||
def google_apis(): | ||
if not settings.WATCHMAN_ENABLE_PAID_CHECKS: | ||
return {} | ||
return {'Google APIs': [_geocode_address()]} |
This file contains 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,31 @@ | ||
import redis | ||
from django.conf import settings | ||
from django.utils.crypto import get_random_string | ||
from watchman.decorators import check | ||
|
||
|
||
@check | ||
def _redis_check_connection(): | ||
try: | ||
redis.StrictRedis.from_url(settings.REDIS_URL) | ||
except Exception as e: | ||
{'Connection': {'ok': False}} | ||
return {'Connection': {'ok': True}} | ||
|
||
|
||
@check | ||
def _redis_check_rw(): | ||
try: | ||
s = get_random_string() | ||
r = redis.StrictRedis.from_url(settings.REDIS_URL) | ||
r.set('watchman_check', s, 30) | ||
v = r.get('watchman_check').decode() | ||
if v != s: | ||
return {'RW': {'ok': False}} | ||
except Exception as e: | ||
return {'RW': {'ok': False}} | ||
return {'RW': {'ok': True}} | ||
|
||
|
||
def redis_check(): | ||
return {'redis': [_redis_check_connection(), _redis_check_rw()]} |
This file contains 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,19 @@ | ||
from watchman.decorators import check | ||
|
||
|
||
@check | ||
def _caronas_unicamp(): | ||
return {'Caronas Unicamp': {'ok': True}} | ||
|
||
|
||
@check | ||
def _blablacar(): | ||
return {'API': {'ok': True}} | ||
|
||
|
||
def facebook(): | ||
return {'Facebook Groups': [_caronas_unicamp()]} | ||
|
||
|
||
def blablacar(): | ||
return {'BlaBlaCar': [_blablacar()]} |
Oops, something went wrong.