Start adding code

This commit is contained in:
Matthias 2020-09-05 23:12:54 -04:00
parent 7cbf9f9e3a
commit 93710fe834
12 changed files with 89 additions and 1 deletions

0
main/__init__.py Normal file
View File

3
main/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
main/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class MainConfig(AppConfig):
name = 'main'

View File

@ -0,0 +1,24 @@
# Generated by Django 3.1.1 on 2020-09-06 02:53
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Thought',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.CharField(max_length=140)),
('extended_text', models.TextField(blank=True)),
('posted', models.DateTimeField()),
('timezone_offset', models.IntegerField()),
],
),
]

View File

9
main/models.py Normal file
View File

@ -0,0 +1,9 @@
from django.db import models
class Thought(models.Model):
text = models.CharField(max_length=140)
extended_text = models.TextField(blank=True)
posted = models.DateTimeField()
timezone_offset = models.IntegerField() # The number of minutes behind UTC we were when this was posted

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hello, and welcome to the index.
</body>
</html>

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="{% url 'post'%}" method="post">
{% csrf_token %}
<label>
<textarea></textarea>
</label>
</form>
</body>
</html>

16
main/views.py Normal file
View File

@ -0,0 +1,16 @@
from django.shortcuts import render
from .models import Thought
def index(request):
return render(request, "whispermaphone/index.html", {})
def post(request):
if request.method == "POST":
# offset = request["POST"].timezone_offset
# Thought(text=, extended_text=, posted=, timezone_offset=, )
pass
else:
return render(request, "whispermaphone/post.html", {})

View File

View File

@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
]
MIDDLEWARE = [

View File

@ -16,6 +16,9 @@ Including another URLconf
from django.contrib import admin
from django.urls import path
from main import views
urlpatterns = [
path('admin/', admin.site.urls),
path("", views.index),
path("post", views.post),
]