-
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
12 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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,17 @@ | ||
from typing import List | ||
from ninja import NinjaAPI, Schema, ModelSchema, Field | ||
|
||
from gobabygo.models import User | ||
|
||
api = NinjaAPI() | ||
|
||
|
||
class UserEchoSchema(ModelSchema): | ||
class Meta: | ||
model = User | ||
fields = ["id", "username", "first_name", "last_name"] | ||
|
||
|
||
@api.get("/whoami", response=UserEchoSchema) | ||
def whoami(request): | ||
return request.user |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class gobabygoConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "gobabygo" |
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
{% block head %} | ||
<meta name="ENVIRONMENT" value="{{ settings.ENVIRONMENT }}"> | ||
<meta name="ENVIRONMENT" value="{{ settings.SENTRY_DSN }}"> | ||
{{ render_bundle('app', 'css') }} | ||
{% endblock %} | ||
</head> | ||
<body> | ||
{% block content %} | ||
{% endblock %} | ||
|
||
{% block foot %} | ||
{{ render_bundle('app', 'js') }} | ||
{% endblock %} | ||
</body> | ||
</html> |
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,11 @@ | ||
{% extends 'base.jinja2' %} | ||
|
||
{% block content %} | ||
Hello World | ||
|
||
<ul> | ||
<li><a href="/vue/test">Vue-router base</a></li> | ||
<li><a href="/api/whoami">API</a></li> | ||
<li><a href="/admin">Admin</a></li> | ||
</ul> | ||
{% endblock %} |
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,6 @@ | ||
{% extends 'base.jinja2' %} | ||
|
||
{% block content %} | ||
<div id="vue-router-base"> | ||
</div> | ||
{% endblock %} |
Empty file.
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,29 @@ | ||
from django.contrib.auth.models import AbstractUser | ||
from django.db import models | ||
|
||
from timezone_field import TimeZoneField | ||
|
||
|
||
class User(AbstractUser): | ||
email = models.EmailField(blank=False, unique=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
|
||
USERNAME_FIELD = "email" | ||
REQUIRED_FIELDS = ["username"] | ||
|
||
def save(self, *args, **kwargs): | ||
super().save(*args, **kwargs) | ||
|
||
if not hasattr(self, "profile"): | ||
Profile.objects.create(user=self) | ||
|
||
|
||
class Profile(models.Model): | ||
user = models.OneToOneField(User, on_delete=models.CASCADE) | ||
tz = TimeZoneField(default="America/New_York", verbose_name="Timezone") | ||
|
||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
|
||
def __str__(self): | ||
return f"{self.user.email}'s profile" |
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 django.templatetags.static import static | ||
from django.urls import reverse | ||
from django.conf import settings | ||
|
||
from jinja2 import Environment | ||
|
||
|
||
def environment(**options): | ||
env = Environment(**options) | ||
env.globals.update( | ||
{ | ||
"static": static, | ||
"url": reverse, | ||
"settings": { | ||
"ENVIRONMENT": settings.ENVIRONMENT, | ||
}, | ||
} | ||
) | ||
return env |
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,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
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 @@ | ||
from django.shortcuts import render | ||
|
||
|
||
def index(request): | ||
return render(request, 'index.jinja2') | ||
|
||
|
||
def vue_index(request): | ||
return render(request, "vue_base.jinja2") |