Skip to content
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

Finished assignment #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore

This file was deleted.

Binary file added blogging/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added blogging/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added blogging/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added blogging/__pycache__/tests.cpython-36.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions blogging/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from blogging.models import Post

admin.site.register(Post)
from blogging.models import Post

admin.site.register(Post)
2 changes: 1 addition & 1 deletion blogging/fixtures/blogging_test_fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"date_joined": "2013-05-24T05:35:58.628Z"
}
}
]
]
2 changes: 1 addition & 1 deletion blogging/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.1.1 on 2019-10-29 01:39
# Generated by Django 2.1.1 on 2020-05-18 15:31

from django.conf import settings
from django.db import migrations, models
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion blogging/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
from django.contrib.auth.models import User

class Post(models.Model):

title = models.CharField(max_length=128)
text = models.TextField(blank=True)
author = models.ForeignKey(User, on_delete=models.CASCADE)
created_date = models.DateTimeField(auto_now_add=True)
modified_date = models.DateTimeField(auto_now=True)
published_date = models.DateTimeField(blank=True, null=True)



def __str__(self):
return self.title

6 changes: 2 additions & 4 deletions blogging/tests.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
from django.test import TestCase
from django.contrib.auth.models import User

from blogging.models import Post


class PostTestCase(TestCase):
fixtures = ['blogging_test_fixture.json', ]

def setUp(self):
self.user = User.objects.get(pk=1)

def test_string_representation(self):
expected = "This is a title"
p1 = Post(title=expected)
actual = str(p1)
self.assertEqual(expected, actual)
self.assertEqual(expected, actual)
Binary file added db.sqlite3
Binary file not shown.
Binary file added mysite/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added mysite/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file added mysite/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added mysite/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'xak=ca*e6hvh8q5hgfz5l9ees)_pxjif0)ui!ikifg4!enjk+7'
SECRET_KEY = '9@s4f=3pgo)l2(#*zoogaurq$#v*%bi1d9cmim1(z(2budl@!%'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down
4 changes: 3 additions & 1 deletion mysite/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{# mysite/templates/base.html #}

<!DOCTYPE html>
<html>
<head>
Expand All @@ -12,4 +14,4 @@
</div>
</div>
</body>
</html>
</html>`
Binary file added polling/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file added polling/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file added polling/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file added polling/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file added polling/__pycache__/views.cpython-36.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion polling/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# blogging/admin.py
from django.contrib import admin
from polling.models import Poll

admin.site.register(Poll)
admin.site.register(Poll)
2 changes: 1 addition & 1 deletion polling/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 2.1.1 on 2019-10-29 01:24
# Generated by Django 2.1.1 on 2020-05-18 14:54

from django.db import migrations, models

Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion polling/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# blogging/models.py
from django.db import models

class Poll(models.Model):
Expand All @@ -6,4 +7,4 @@ class Poll(models.Model):
score = models.IntegerField(default=0)

def __str__(self):
return self.title
return self.title
2 changes: 1 addition & 1 deletion polling/templates/polling/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ <h1>{{ poll.title }}</h1>
<input type="submit" name="vote" value="No">
</form>
</div>
{% endblock %}
{% endblock %}
4 changes: 3 additions & 1 deletion polling/templates/polling/list.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{# polling/templates/polling/list.html #}

{% extends "base.html" %}
{% block content %}
<h1>Polls</h1>
Expand All @@ -8,4 +10,4 @@ <h2>
</h2>
</div>
{% endfor %}
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion polling/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
urlpatterns = [
path('', list_view, name="poll_index"),
path('polls/<int:poll_id>/', detail_view, name="poll_detail"),
]
]
4 changes: 3 additions & 1 deletion polling/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# polling/views.py

from django.shortcuts import render
from django.http import Http404
from polling.models import Poll
Expand All @@ -20,4 +22,4 @@ def detail_view(request, poll_id):
poll.save()

context = {'poll': poll}
return render(request, 'polling/detail.html', context)
return render(request, 'polling/detail.html', context)