Skip to content

Commit

Permalink
Fix renamed directory
Browse files Browse the repository at this point in the history
  • Loading branch information
drien committed Jan 14, 2024
1 parent 74a0218 commit c072d4a
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 0 deletions.
Empty file added gobabygo/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions gobabygo/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
17 changes: 17 additions & 0 deletions gobabygo/api.py
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
6 changes: 6 additions & 0 deletions gobabygo/apps.py
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"
18 changes: 18 additions & 0 deletions gobabygo/jinja2/base.jinja2
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>
11 changes: 11 additions & 0 deletions gobabygo/jinja2/index.jinja2
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 %}
6 changes: 6 additions & 0 deletions gobabygo/jinja2/vue_base.jinja2
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 added gobabygo/migrations/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions gobabygo/models.py
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"
19 changes: 19 additions & 0 deletions gobabygo/templating.py
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
3 changes: 3 additions & 0 deletions gobabygo/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions gobabygo/views.py
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")

0 comments on commit c072d4a

Please sign in to comment.