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

Directory change 2 #18

Open
wants to merge 1 commit into
base: main
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
62 changes: 0 additions & 62 deletions .github/workflows/main_WorldPoster.yml

This file was deleted.

File renamed without changes.
Binary file added App/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added App/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added App/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file added App/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file added App/__pycache__/tests.cpython-39.pyc
Binary file not shown.
Binary file added App/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added App/__pycache__/views.cpython-39.pyc
Binary file not shown.
12 changes: 12 additions & 0 deletions App/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin

# Register your models here.
from .models import Post


class PostAdmin(admin.ModelAdmin):
list_display = ('title', 'slug', 'status', 'created_on')
list_filter = ('status',)
search_fields = ['title', 'content']

admin.site.register(Post, PostAdmin)
5 changes: 5 additions & 0 deletions App/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AppConfig(AppConfig):
name = 'App'
33 changes: 33 additions & 0 deletions App/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.1.7 on 2021-09-26 22:19

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200, unique=True)),
('slug', models.SlugField(max_length=200, unique=True)),
('created_on', models.DateTimeField(auto_now_add=True)),
('updated_on', models.DateTimeField(auto_now=True)),
('content', models.TextField()),
('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=0)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_posts', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_on'],
},
),
]
Binary file not shown.
Binary file added App/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions App/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.db import models
from django.contrib.auth.models import User
# Create your models here.

STATUS = ((0, "Draft"), (1, "Published"))

class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='blog_posts')
created_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now=True)
content = models.TextField()
status = models.IntegerField(choices=STATUS, default=0)

class Meta:
ordering = ['-created_on']

def __str__(self):
return self.title

# class Comment(models.Model):
# post = models.ForeignKey(Post, related_name='comments', on_delete=models.CASCADE)
# name = models.CharField(max_length=255)
# email = models.EmailField()
# body = models.TextField()
# date_added = models.DateTimeField(auto_now_add=True)

# class Meta:
# ordering = ['date_added']
43 changes: 43 additions & 0 deletions App/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>

<head>
<title>My Blog App</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Bootstrap cdn -->
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/journal/bootstrap.min.css"> -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/flatly/bootstrap.min.css">

<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/sketchy/bootstrap.min.css"> -->
</head>

<body>
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary" id="mainNav">
<div class="container-fluid">
<a class="navbar-brand" href="{% url 'home' %}">🌐Daily Blog Posts🌐</a>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item text-black">
<a class="nav-link text-black font-weight-bold" href="#">Reports</a>
</li>
<li class="nav-item text-black">
<a class="nav-link text-black font-weight-bold" href="#">Policy</a>
</li>
<li class="nav-item text-black">
<a class="nav-link text-black font-weight-bold" href="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
{% block content %}
<!-- Content Goes here -->
{% endblock content %}
<!-- Footer -->
<footer class="py-3 bg-grey">
<p class="m-0 text-dark text-center ">Copyright &copy; 2021 My Blog App </p>
</footer>
</body>

</html>
36 changes: 36 additions & 0 deletions App/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block content %}
<header class="masthead">
<div class="overlay"></div>
<div class="container">
<div class="row">
<div class=" col-md-8 col-md-10 mx-auto">
<div class="site-heading">
<h3 class=" site-heading my-4 mt-3 text-black"> Welcome to My Blog ✍️ </h3>
<p class="text-dark">Django is Awesome ✨✨✨ </p>
</div>
</div>
</div>
</div>
</header>
<div class="container">
<div class="row">
<!-- Blog Entries Column -->
<div class="col-md-8 mt-3 left">
{% for post in post_list %}
<div class="card mb-4">
<div class="card-body">
<h2 class="card-title">{{ post.title }}</h2>
<p class="card-text text-muted h6">{{ post.author }} | {{ post.created_on}} </p>
<p class="card-text">{{post.content|slice:":200"}}</p>
<a href="{% url 'post_detail' post.slug %}" class="btn btn-primary">Read More &rarr;</a>
</div>
</div>
{% endfor %}
</div>
{% block sidebar %}
{% include 'sidebar.html' %}
{% endblock sidebar %}
</div>
</div>
{%endblock%}
17 changes: 17 additions & 0 deletions App/templates/post_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block content %}

<div class="container">
<div class="row">
<div class="col-md-8 card mb-4 mt-3 left top">
<div class="card-body">
<h1>{% block title %} {{ object.title }} {% endblock title %}</h1>
<p class=" text-muted">{{ post.author }} | {{ post.created_on }}</p>
<p class="card-text ">{{ object.content | safe }}</p>
</div>
</div>
{% block sidebar %} {% include 'sidebar.html' %} {% endblock sidebar %}
</div>
</div>

{% endblock content %}
22 changes: 22 additions & 0 deletions App/templates/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% block sidebar %}

<style>
.card {
box-shadow: 0 16px 48px #6a6a6b;
}
</style>

<!-- Sidebar Widgets Column -->
<div class="col-md-4 float-right ">
<div class="card my-4">
<h5 class="card-header">About</h5>
<div class="card-body">
<p class="card-text"> My Blog App is created using Django Web Framework for backend side, designed with bootswatch
theme for UI - you can also visit my website ... </p>
<a href="" class="btn btn-danger">Visit Website!</a>
<a href=" class="btn btn-secondary">Django Docs</a>
</div>
</div>
</div>

{% endblock sidebar %}
33 changes: 33 additions & 0 deletions App/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from django.test import TestCase, Client

# Create your tests here.
from .models import Post,User

class Test_Blog(TestCase):

def setUp(self):
#create User
a = User.objects.create_user(username='testuser', password='12345')
#create Blog
b1 = Post.objects.create(title = "A",slug="A", author=a , content="ABCD", status=0)
b2 = Post.objects.create(title = "B",slug="B", author=a , content="Sri lanka", status=1)
b3 = Post.objects.create(title = "C",slug="C", author=a , content="Blog", status=1)

def test_index(self):
""" Test index page """
# Set up client to make requests
c = Client()
# Send get request to index page and store response
response = c.get("/")
# Make sure status code is 200
self.assertEqual(response.status_code, 200)

def test_live_post(self):
count = 0
for x in Post.objects.all():
if x.status == 1:
count+=1

self.assertTrue(count==2)


7 changes: 7 additions & 0 deletions App/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from . import views
from django.urls import path

urlpatterns = [
path('', views.PostList.as_view(), name="home"),
path('<slug:slug>/', views.DetailView.as_view(), name="post_detail"),
]
15 changes: 15 additions & 0 deletions App/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.shortcuts import render
from .models import Post
from django.views import generic
# Create your views here.

class PostList(generic.ListView):
queryset = Post.objects.filter(status=1).order_by('-created_on')
template_name = 'index.html'


class DetailView(generic.DetailView):
model = Post
template_name = 'post_detail.html'


Binary file removed Assets/Agile Requirment Gathering.JPG
Binary file not shown.
Binary file removed Assets/User stories.JPG
Binary file not shown.
Binary file removed Assets/User story.JPG
Binary file not shown.
Loading