-
Notifications
You must be signed in to change notification settings - Fork 3
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
Mehedi Hasan
committed
Dec 11, 2020
0 parents
commit 3275c50
Showing
47 changed files
with
869 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,4 @@ | ||
from django.contrib import admin | ||
from .models import Post | ||
|
||
admin.site.register(Post) |
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,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BlogConfig(AppConfig): | ||
name = 'blog' |
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,28 @@ | ||
# Generated by Django 3.1.4 on 2020-12-09 04:27 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
|
||
|
||
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=100)), | ||
('content', models.TextField()), | ||
('date_posted', models.DateTimeField(default=django.utils.timezone.now)), | ||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
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,17 @@ | ||
from django.db import models | ||
from django.utils import timezone | ||
from django.contrib.auth.models import User | ||
from django.urls import reverse | ||
|
||
class Post(models.Model): | ||
title = models.CharField(max_length=100) | ||
content = models.TextField() | ||
date_posted = models.DateTimeField(default=timezone.now) | ||
author = models.ForeignKey(User, on_delete=models.CASCADE) | ||
|
||
def __str__(self): | ||
return self.title | ||
|
||
|
||
def get_absolute_url(self): | ||
return reverse('post-detail', kwargs={'pk': self.pk}) |
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,85 @@ | ||
body { | ||
background: #fafafa; | ||
color: #333333; | ||
margin-top: 5rem; | ||
} | ||
|
||
h1, h2, h3, h4, h5, h6 { | ||
color: #444444; | ||
} | ||
|
||
ul { | ||
margin: 0; | ||
} | ||
|
||
.bg-steel { | ||
background-color: #5f788a; | ||
} | ||
|
||
.site-header .navbar-nav .nav-link { | ||
color: #cbd5db; | ||
} | ||
|
||
.site-header .navbar-nav .nav-link:hover { | ||
color: #ffffff; | ||
} | ||
|
||
.site-header .navbar-nav .nav-link.active { | ||
font-weight: 500; | ||
} | ||
|
||
.content-section { | ||
background: #ffffff; | ||
padding: 10px 20px; | ||
border: 1px solid #dddddd; | ||
border-radius: 3px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.article-title { | ||
color: #444444; | ||
} | ||
|
||
a.article-title:hover { | ||
color: #428bca; | ||
text-decoration: none; | ||
} | ||
|
||
.article-content { | ||
white-space: pre-line; | ||
} | ||
|
||
.article-img { | ||
height: 65px; | ||
width: 65px; | ||
margin-right: 16px; | ||
} | ||
|
||
.article-metadata { | ||
padding-bottom: 1px; | ||
margin-bottom: 4px; | ||
border-bottom: 1px solid #e3e3e3 | ||
} | ||
|
||
.article-metadata a:hover { | ||
color: #333; | ||
text-decoration: none; | ||
} | ||
|
||
.article-svg { | ||
width: 25px; | ||
height: 25px; | ||
vertical-align: middle; | ||
} | ||
|
||
.account-img { | ||
height: 125px; | ||
width: 125px; | ||
margin-right: 20px; | ||
margin-bottom: 16px; | ||
} | ||
|
||
.account-heading { | ||
font-size: 2.5rem; | ||
} | ||
|
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,5 @@ | ||
{% extends "blog/base.html" %} | ||
|
||
{% block content %} | ||
<h1>About page!</h1> | ||
{% endblock content %} |
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,106 @@ | ||
{% load static %} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
|
||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous"> | ||
<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}"> | ||
{% if title %} | ||
<title>CyberExpert | {{ title }} </title> | ||
{% else %} | ||
<title>CyberExpert</title> | ||
{% endif %} | ||
</head> | ||
<body> | ||
|
||
<header class="site-header"> | ||
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top"> | ||
<div class="container"> | ||
<a class="navbar-brand mr-4" href=" {% url 'blog-home' %} ">CyberExpert</a> | ||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarToggle"> | ||
<div class="navbar-nav mr-auto"> | ||
<a class="nav-item nav-link" href=" {% url 'blog-home' %} ">Blogs</a> | ||
<a class="nav-item nav-link" href=" {% url 'blog-about' %} ">About</a> | ||
<h5>______________________________________________________________________________</h5> | ||
</div> | ||
<!-- Navbar Right Side --> | ||
<div class="navbar-nav"> | ||
{% if user.is_authenticated %} | ||
<a class="nav-item nav-link" href="{% url 'post-create' %}"> New Post</a> | ||
<a class="nav-item nav-link" href="{% url 'profile' %}">Profile</a> | ||
<a class="nav-item nav-link" href="{% url 'logout' %}">Log Out</a> | ||
|
||
{% else %} | ||
<a class="nav-item nav-link" href="{% url 'login' %}">Login</a> | ||
<a class="nav-item nav-link" href="{% url 'register' %}">Register</a> | ||
{% endif %} | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
|
||
<main role="main" class="container"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
{% if messages %} | ||
{% for message in messages %} | ||
|
||
<div class="alert alert-{{ message.tags }}"> | ||
{{ message }} | ||
</div> | ||
|
||
|
||
{% endfor %} | ||
{% endif %} | ||
|
||
{% block content %}{% endblock %} | ||
|
||
{% if user.is_authenticated %} | ||
</div> | ||
<div class="col-md-4"> | ||
<div class="content-section"> | ||
<h3>Quick Access</h3> | ||
<p class='text-muted'>This section is under development, so It won't work right now. | ||
<ul class="list-group"> | ||
<li class="list-group-item list-group-item-light">Ask a Question</li> | ||
<li class="list-group-item list-group-item-light">Hire Speacialist</li> | ||
<li class="list-group-item list-group-item-light">Help Others</li> | ||
<li class="list-group-item list-group-item-light">Tutorials</li> | ||
<li class="list-group-item list-group-item-light">Emergency</li> | ||
|
||
</ul> | ||
</p> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
</main> | ||
|
||
|
||
<footer> | ||
<center>Copyright © 2020 CyberExpert.</center> | ||
</footer> | ||
|
||
<!-- Optional JavaScript; choose one of the two! --> | ||
|
||
<!-- Option 1: Bootstrap Bundle with Popper --> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script> | ||
|
||
<!-- Option 2: Separate Popper and Bootstrap JS --> | ||
<!-- | ||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-q2kxQ16AaE6UbzuKqyBE9/u/KzioAlnx2maXQHiDX9d4/zp8Ok3f+M7DPm+Ib6IU" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-pQQkAEnwaBkjpqZ8RU1fF1AKtTcHJwFl3pblpTlHXybJjHpMYo79HY3hIi4NKxyj" crossorigin="anonymous"></script> | ||
--> | ||
</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,33 @@ | ||
{% extends "blog/base.html" %} | ||
|
||
{% block content %} | ||
|
||
{% if user.is_authenticated %} | ||
|
||
{% for post in posts %} | ||
<article class="media content-section"> | ||
|
||
<img class="rounded-circle article-img" src=" {{ post.author.profile.image.url }} "> | ||
|
||
|
||
|
||
<div class="media-body"> | ||
<div class="article-metadata"> | ||
<a class="mr-2" href="#">{{ post.author }}</a> | ||
<small class="text-muted">{{ post.date_posted }}</small> | ||
</div> | ||
<h2><a class="article-title" href=" {% url 'post-detail' post.id %} ">{{ post.title }}</a></h2> | ||
<p class="article-content">{{ post.content }}</p> | ||
</div> | ||
</article> | ||
{% endfor %} | ||
|
||
{% else %} | ||
|
||
<h1>Hello, log in first please</h1> | ||
|
||
{% endif %} | ||
|
||
|
||
|
||
{% endblock content %} |
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 @@ | ||
{% extends "blog/base.html" %} | ||
|
||
{% block content %} | ||
<div class="content-section"> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
|
||
<fieldset class="form-group"> | ||
<legend class="border-bottom mb-4">Delete Post</legend> | ||
<h2>Are you sure you want to delete the post "{{ object.title }}"</h2> | ||
</fieldset> | ||
<br> | ||
<div class="form-group"> | ||
<button class="btn btn-outline-danger" type="submit">Yes, Delete</button> | ||
<a class="btn btn-outline-secondary" href="{% url 'post-detail' object.id %}">Cancel</a> | ||
</div> | ||
</form> | ||
</div> | ||
{% endblock content %} |
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 @@ | ||
{% extends "blog/base.html" %} | ||
|
||
{% block content %} | ||
<article class="media content-section"> | ||
<img class="rounded-circle article-img" src=" {{ object.author.profile.image.url }} "> | ||
<div class="media-body"> | ||
<div class="article-metadata"> | ||
<a class="mr-2" href="#">{{ object.author }}</a> | ||
<small class="text-muted">{{ object.date_posted }}</small> | ||
{% if object.author == user %} | ||
<a class="btn btn-secondary btn-sm mt-1 mb-1" href=" {% url 'post-update' object.id %} ">Update</a> | ||
<a class="btn btn-danger btn-sm mt-1 mb-1" href=" {% url 'post-delete' object.id %} ">Delete</a> | ||
{% endif %} | ||
</div> | ||
<h2 class="article-title" > {{ object.title }} </h2> | ||
<p class="article-content">{{ object.content }}</p> | ||
</div> | ||
</article> | ||
{% endblock content %} |
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 @@ | ||
{% extends "blog/base.html" %} | ||
{% load crispy_forms_tags %} | ||
|
||
{% block content %} | ||
<div class="content-section"> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
|
||
<fieldset class="form-group"> | ||
<legend class="border-bottom mb-4">Create a new post</legend> | ||
{{ form|crispy }} | ||
</fieldset> | ||
<br> | ||
<div class="form-group"> | ||
<button class="btn btn-outline-info" type="submit">Post</button> | ||
</div> | ||
</form> | ||
</div> | ||
{% endblock content %} |
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,12 @@ | ||
from django.urls import path | ||
from .views import PostListView, PostDetailView, PostCreateView, PostUpdateView, PostDeleteView | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('', PostListView.as_view(), name ='blog-home'), | ||
path('post/<int:pk>/', PostDetailView.as_view(), name ='post-detail'), | ||
path('post/new/', PostCreateView.as_view(), name ='post-create'), | ||
path('post/<int:pk>/update/', PostUpdateView.as_view(), name ='post-update'), | ||
path('post/<int:pk>/delete/', PostDeleteView.as_view(), name ='post-delete'), | ||
path('about/', views.about, name ='blog-about'), | ||
] |
Oops, something went wrong.