Compare commits

...

2 Commits

Author SHA1 Message Date
surya e232fec118 Cleanup
cleaned up useless code
2024-07-16 14:57:51 +05:30
surya 9cae5bc994 Removed Posts
removed the `posts` class and allied functionality
2024-07-16 14:47:16 +05:30
14 changed files with 18 additions and 288 deletions

View File

@ -12,10 +12,3 @@ class Blog(models.Model):
def get_absolute_url(self): def get_absolute_url(self):
return '/' return '/'
class Post(models.Model):
content = models.TextField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
date_posted = models.DateTimeField(default=timezone.now)

View File

@ -6,8 +6,6 @@ urlpatterns = [
path('news/', views.news, name='News'), path('news/', views.news, name='News'),
path('blog/<int:pk>', views.BlogDetailView.as_view(), name='Blog'), path('blog/<int:pk>', views.BlogDetailView.as_view(), name='Blog'),
path('blog/create/', views.BlogCreateView.as_view(), name='Blog Create'), path('blog/create/', views.BlogCreateView.as_view(), name='Blog Create'),
path('post/<int:pk>', views.PostDetailView.as_view(), name='Post'),
path('post/create/', views.PostCreateView.as_view(), name='Post Create'),
path('dev/', views.dev, name='Dev'), path('dev/', views.dev, name='Dev'),
path('dev/support/', views.support, name='Support'), path('dev/support/', views.support, name='Support'),
] ]

View File

@ -40,6 +40,7 @@ def news(request):
class BlogDetailView(DetailView): class BlogDetailView(DetailView):
model = Blog model = Blog
template_name = 'blog/blogDetail.html' template_name = 'blog/blogDetail.html'
context_object_name = 'objects'
class BlogCreateView(LoginRequiredMixin, CreateView): class BlogCreateView(LoginRequiredMixin, CreateView):
@ -52,22 +53,6 @@ class BlogCreateView(LoginRequiredMixin, CreateView):
return super().form_valid(form) return super().form_valid(form)
class PostDetailView(DetailView):
model = Post
template_name = 'blog/postDetail.html'
class PostCreateView(LoginRequiredMixin, CreateView):
model = Post
template_name = 'blog/postCreate.html'
fields = ['content']
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
def dev(request): def dev(request):
return render(request, 'dev.html', {'title': 'Development'}) return render(request, 'dev.html', {'title': 'Development'})

View File

@ -5,47 +5,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Beyond Heroes</title> <title>Beyond Heroes</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Custom CSS -->
<style>
/* body {
background-color: #f8f9fa;
color: #eeeeee;
}
.card {
border: 1px;
border-radius: 15px;
border-color: #eeeeee;
box-shadow: 0 0 10px rgba(250, 250, 250, 0.1);
}
.list-group-item {
background-color: #1e1f10;
border-color: #eeeeee;
}
.card-header {
background-color: #111111;
border-bottom: 1px solid #eeeeee;
}
.card-body {
background-color: #1e1f10;
}
.profile-image {
max-width: 125px;
border-radius: 50%;
padding: 20px;
}*/
.link {
text-decoration: none;
}
</style>
</head> </head>
<body> <body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #000;"> <nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #000;">
<a class="navbar-brand" href="/"> <a class="navbar-brand" href="/">
<img src="/media/logo.jpg" alt="BH Logo" height="40"> Beyond Heroes <img src="/media/logo.jpg" alt="BH Logo" height="40"> Beyond Heroes
</a> </a>
<!-- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button> -->
<div class="ml-auto"></div> <div class="ml-auto"></div>
<div class="justify-content-center" id="navbarNav"> <div class="justify-content-center" id="navbarNav">
<ul class="navbar-nav"> <ul class="navbar-nav">

View File

@ -1,85 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
{% if title %}
<title>WeBlog - {{ title }}</title>
{% else %}
<title>WeBlog - We connect your brains!</title>
{% endif %}
<link rel="icon" type="image/x-icon" href="WeBlog.ico">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary rounded-bottom" style="background: #a4e5ff; margin-bottom:10px">
<div class="container">
<a class="navbar-brand" href="/">TechBlog</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'About' %}">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'People' %}">People</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'Explore' %}">Explore</a>
</li>
</ul>
<div style="margin-left: 60%;"></div>
<ul class="navbar-nav nav-rev" style="margin-right: 0px;">
{% if user.is_authenticated %}
<li class="nav-item">
<a class="nav-link" id='a' href="{% url 'Blog Create' %}">Post</a>
</li>
<li class="nav-item">
<a class="nav-link" id='a' href="{% url 'Profile' %}">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id='a' href="{% url 'Logout' %}">Logout</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="{% url 'Login' %}">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" id=a href="{% url 'Register' %}">Register</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
<div id="container"
style="font-family: Rockwell; margin-bottom: 0; padding-bottom: 10px; padding-top: 20px; padding-right: 100px; padding-left: 100px;">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% block content %}
{% endblock %}
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

View File

@ -1,42 +0,0 @@
{% extends 'base.html' %}
{% block content %}
<h1 class="display-3" style="font-family: rockwell;"><strong>TechBlog</strong></h1>
<h4 class="lead"><strong>We provide a platform for people who want to help others.</strong></h4>
<hr>
<br>
<ul style="margin-bottom: 100px">
{% for blog in blog %}
<!-- <li>-->
<!-- <h2>{{ blog.title }}</h2>-->
<!-- <p>{{ blog.content }}</p>-->
<!-- <hr>-->
<!-- </li>-->
<blockquote class="blockquote">
<a href="{% url 'Blog' blog.id %}" class="h2" style="font-family: rockwell; color:rgb(0, 92, 167);">{{ blog.title }}</a>
<p class="mb-0">{{ blog.content }}</p>
<footer class="blockquote-footer">posted by <cite title="{{ blog.author }}"><a href="{% url 'NamedProfile' blog.author.id %}">{{ blog.author }}</a></cite> on <cite title="{{ blog.date_posted }}">{{ blog.date_posted|date:"M j, o" }}</cite></footer>
</blockquote>
<hr>
<!-- <li class="media">-->
<!-- <img src="..." class="mr-3" alt="...">-->
<!-- <div class="media-body">-->
<!-- <h5 class="mt-0 mb-1">{{ blog.title }}</h5>-->
<!-- {{ blog.content }}-->
<!-- </div>-->
<!-- </li>-->
<!-- <hr>-->
<!-- <br>-->
<!-- <div class="card">-->
<!-- <div class="card-header">-->
<!-- {{ blog.author }}-->
<!-- </div>-->
<!-- <div class="card-body">-->
<!-- <h5 class="card-title">{{ blog.title }}</h5>-->
<!-- <p class="card-text">{{ blog.content }}</p>-->
<!-- <a href="#" class="btn btn-primary">Read More</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- <br>-->
{% endfor %}
</ul>
{% endblock %}

View File

@ -13,11 +13,6 @@
<br> <br>
<button class="btn btn-light" type="submit"> Post </button> <button class="btn btn-light" type="submit"> Post </button>
</div> </div>
<!-- <div class="card-footer">
<small class="text-muted">
Don't Have An Account? <a class="link" href="{% url 'Register' %}">Register</a>
</small>
</div> -->
</div> </div>
</form> </form>
</div> </div>

View File

@ -1,12 +1,21 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% block content %}
{% load markdown_extras %} {% load markdown_extras %}
<br> <div class="container mt-5">
<blockquote class="blockquote">
<h2 class="h2" style="font-family: rockwell;">{{ object.title | markdown | safe }}</h2> {% for object in objects %}
<p class="mb-0">{{ object.content | markdown | safe }}</p> <div class="card mb-3">
<footer class="blockquote-footer">posted by <cite title="{{ object.author }}"><a href="{% url 'NamedProfile' blog.author.id %}">{{ object.author }}</a></cite> on <cite title="{{ object.date_posted }}">{{ object.date_posted|date:"M j, o" }}</cite></footer> <div class="card-body">
</blockquote> <h5 class="card-title">{{ object.title | markdown | safe }}</h5>
<hr style="margin-bottom: 20px"> <p class="card-text">{{ object.content | markdown | safe }}</p>
</div>
<div class="card-footer">
By <cite title="{{ object.author }}"><a href="#">{{ object.author }}</a></cite> on <cite title="{{ object.date_posted }}">{{ object.date_posted|date:"M j, o" }}</cite>
</div>
</div>
{% endfor %}
</div>
{% endblock %} {% endblock %}

View File

@ -1,32 +0,0 @@
{% extends 'base.html' %}
{% block content %}
{% load markdown_extras %}
<div style="">
<h1 class="h1">We Blog</h1>
<p class="lead">We connect your brains!</p>
<hr class="my-4" />
</div>
<ul class="list-unstyled">
{% for post in blogs %}
<div class="jumbotron" id="jumbotron" style="background-color: #ffffff60;">
<li class="media">
<article class="media content-section">
<div class="media-body">
<div class="article-metadata">
<a class="mr-2" href="{% url 'NamedProfile' post.author.id %}">{{ post.author }}</a>
<small class="text-muted">{{ post.data_posted|date:"M j, Y" }}</small>
<br>
</div>
<a class="article-title" style="font-size: 40px;" href="{% url 'Blog' post.id %}">{{ post.title | markdown | safe }}</a>
<hr class="my-4" />
<p class="article-content">{{ post.content | markdown | safe }}</p>
</div>
</article>
</li>
</div>
{% endfor %}
</ul>
</div>
{% endblock %}

View File

@ -1,24 +0,0 @@
{% extends 'base.html' %}
{% block content %}
{% load crispy_forms_tags %}
<div class="container mt-5">
<form method="POST">
{% csrf_token %}
<div class="card mb-4">
<div class="card-header">
Create a Post
</div>
<div class="card-body">
{{ form | crispy }}
<br>
<button class="btn btn-light" type="submit"> Post </button>
</div>
<div class="card-footer">
<small class="text-muted">
Don't Have An Account? <a class="link" href="{% url 'Register' %}">Register</a>
</small>
</div>
</div>
</form>
</div>
{% endblock %}

View File

@ -1,18 +0,0 @@
{% extends 'base2.html' %}
{% block content %}
{% load markdown_extras %}
<br>
<blockquote class="blockquote">
<p class="mb-0">{{ object.content | markdown | safe }}</p>
<footer class="blockquote-footer">posted by <cite title="{{ object.author }}"><a href="{% url 'NamedProfile' blog.author.id %}">{{ object.author }}</a></cite> on <cite title="{{ object.date_posted }}">{{ object.date_posted|date:"M j, o" }}</cite></footer>
</blockquote>
<hr style="margin-bottom: 20px">
{% for comment in object.comments %}
<blockquote class="blockquote" style="margin-left: 10px;">
<p class="mb-1">{{ comment.content | markdown | safe }}</p>
<footer class="blockquote-footer">posted by <cite title="{{ comment.author }}"><a href="{% url 'NamedProfile' comment.author.id %}">{{ comment.author }}</a></cite> on <cite title="{{ comment.date_posted }}">{{ comment.date_posted|date:"M j, o" }}</cite></footer>
</blockquote>
<hr style="margin-bottom: 10px; margin-left: 10px;">
{% endfor %}
{% endblock %}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View File

@ -55,25 +55,11 @@ def profile(request, *args, **kwargs):
return render(request, 'users/profile.html', {'title': 'Profile', 'profileUser': user, context_object_name: queryset}) return render(request, 'users/profile.html', {'title': 'Profile', 'profileUser': user, context_object_name: queryset})
def people(request):
return render(request, 'users/people.html', {'title': 'People', 'users': User._default_manager.all()})
users = { users = {
'user': User.objects.all() 'user': User.objects.all()
} }
class UserListView(ListView):
model = User
template_name = 'users/people.html'
context_object_name = 'users'
def explore(request):
return render(request, 'users/explore.html', {'title': 'Explore'})
def login(request): def login(request):
return render(request, 'users/login.html', {'title': 'Login'}) return render(request, 'users/login.html', {'title': 'Login'})