Skip to content

Commit

Permalink
Misc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilanchal Panigrahy committed Dec 26, 2023
1 parent 4221499 commit 948e4aa
Show file tree
Hide file tree
Showing 47 changed files with 337 additions and 221 deletions.
3 changes: 2 additions & 1 deletion bloggy/admin/page_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ class PageAdmin(BloggyAdmin):
list_display = (
'id',
'title',
'template_type',
'url',
'excerpt',
'publish_status',
)

fieldsets = (
(None, {
'fields': ('title', 'excerpt', 'url', 'content',)
'fields': ('title', 'template_type', 'excerpt', 'url', 'content',)
}), publication_fieldsets, seo_fieldsets)

search_fields = ['title']
Expand Down
53 changes: 53 additions & 0 deletions bloggy/management/commands/newsletter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"updates": {
"heading": "In the news this week..",
"list": [
{
"title": "Project Lombok-Is it Still Relevant in 2023?",
"thumbnail": "https://media.stacktips.com/media/uploads/posts/Project_Lombok.jpg",
"link": "https://stacktips.com/articles/project-lombok-is-it-still-relevant-in-2023",
"excerpt": "What is Project Lombok? Have you used this magical library? With the new Java Records feature, you might wonder if Lombok is still relevant. Let's weigh the pros and cons and see if this is suitable for you."
},
{
"title": "Notes to Crack CLF-C01 AWS Certified Cloud Practitioner Exam on First Attempt",
"thumbnail": "https://media.stacktips.com/media/uploads/articles/crack-clfc01-aws-certified-cloud-practitioner-in-first-attempt.jpeg",
"link": "https://stacktips.com/articles/crack-clfc01-aws-certified-cloud-practitioner-on-first-attempt",
"excerpt": "A quick guide to CLF-C01 AWS Certified Cloud Practitioner Practice exam notes covers the introduction to all the services provided by AWS."
},
{
"title": "Replace Embedded Tomcat with Jetty or Undertow Server in Spring Boot 3",
"thumbnail": "https://i3.ytimg.com/vi/1gEoiMVULt4/maxresdefault.jpg",
"link": "https://youtu.be/1gEoiMVULt4",
"excerpt": "This video explains how to replace the default embedded Tomcat with Jetty or Undertow servers"
},
{
"title": "Schedule Task in Spring Boot Using @Scheduled Annotation",
"thumbnail": "",
"link": "https://stacktips.com/articles/schedule-task-in-spring-boot-using-scheduled-annotation",
"excerpt": "Scheduling task in Spring boot using @Scheduled annotation with examples showcasing fixed rate, fixed delay, and using cron expressions."
}
]
},

"news": {
"heading": "In the news this week..",
"list": [
{
"title": "Elon Musk's 'Anti-Woke' AI Is Here, Snowflakes Need Not Apply",
"link": "#"
},
{
"title": "Channel 4 and Snapchat extend and enhance partnership with 'Snap-first' programming",
"link": "#"
},
{
"title": "TikTok adds comment filtering tools to better handle Israel-Hamas war content",
"link": "#"
},
{
"title": "GTA trailer dropped early after leak and breaks all records.",
"link": "#"
}
]
}
}
47 changes: 47 additions & 0 deletions bloggy/management/commands/send_newsletter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from django.core.management.base import BaseCommand
from bloggy import settings
from bloggy.models.subscriber import Subscribers
from bloggy.services import email_service
from bloggy.models import User
from itertools import chain


class Command(BaseCommand):
help = 'Send wish card to users'

def add_arguments(self, parser):
parser.add_argument('--content', type=str, required=True, help='URL of the card')
parser.add_argument('--subject', type=str, required=True, help='Email subject')

def handle(self, *args, **options):
content = options['content']
subject = options['subject']

if content is None or subject is None:
self.stdout.write(
self.style.ERROR(f"Missing mandatory arguments --content or --subject"))

else:
users = chain(
User.objects.all(),
Subscribers.objects.all(),
)

email_count = 0
for user in users:
args = {
"user_name": user.name,
"email_subject": subject,
"app_name": settings.SITE_TITLE,
"updates": ""
}

try:
email_service.send_custom_email(subject, [user.email], "email/wish_card_email.html", args)
print('Success: Card sent to {}', user.email)
except Exception as ex:
print('Error sending card to {}: {}', user.email, ex)
finally:
email_count = email_count + 1

self.stdout.write(self.style.SUCCESS(f"Reminder sent to {email_count} users"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.7 on 2023-12-22 15:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bloggy', '0004_remove_redirectrule_is_regx'),
]

operations = [
migrations.AddField(
model_name='page',
name='template_type',
field=models.CharField(blank=True, choices=[('naked', 'Naked'), ('default', 'Default'), ('wide', 'Wide')], default='default', help_text='Template type', max_length=20, null=True, verbose_name='Template type'),
),
migrations.AlterField(
model_name='post',
name='post_type',
field=models.CharField(blank=True, choices=[['post', 'Post']], default='article', help_text='Post type', max_length=20, null=True, verbose_name='Post type'),
),
migrations.AlterField(
model_name='vote',
name='post_type',
field=models.CharField(choices=[['post', 'Post']], help_text='Select content type', max_length=20, verbose_name='Content type'),
),
]
18 changes: 18 additions & 0 deletions bloggy/migrations/0006_alter_page_template_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-22 16:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bloggy', '0005_page_template_type_alter_post_post_type_and_more'),
]

operations = [
migrations.AlterField(
model_name='page',
name='template_type',
field=models.CharField(blank=True, choices=[('newsletter', 'Newsletter'), ('naked', 'Naked'), ('default', 'Default')], default='default', help_text='Template type', max_length=20, null=True, verbose_name='Template type'),
),
]
10 changes: 10 additions & 0 deletions bloggy/models/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ class Page(Updatable, SeoAware):
"""

title = models.CharField(max_length=300, help_text='Enter title')
template_type = models.CharField(
max_length=20, choices=[
('newsletter', 'Newsletter'),
('naked', 'Naked'),
('default', 'Default'),
],
default='default', blank=True, null=True,
help_text="Template type",
verbose_name="Template type")

excerpt = models.CharField(
max_length=500,
help_text='Enter excerpt',
Expand Down
2 changes: 1 addition & 1 deletion bloggy/models/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Post(Content):
max_length=20, choices=[
('beginner', 'Beginner'),
('intermediate', 'Intermediate'),
('advance', 'advance'),
('advance', 'Advance'),
],
default='easy', blank=True, null=True,
help_text="Select difficulty",
Expand Down
3 changes: 3 additions & 0 deletions bloggy/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def get_full_name_or_username(self):

return self.username

def __str__(self):
return self.get_full_name_or_username()

def get_full_name(self):
full_name = f"{self.name}"
return full_name.strip()
Expand Down
2 changes: 1 addition & 1 deletion bloggy/templates/base-with-header-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{% endif %}
{% block content %}{% endblock content %}
</main>
<footer class="footer mt-auto">
<footer class="footer mt-5">
{% include "partials/footer.html" %}
</footer>
</body>
Expand Down
12 changes: 6 additions & 6 deletions bloggy/templates/pages/archive/posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<div class="col mb-3">
{% include "partials/post_list_item.html" with post=post cssClass="card-rounded" %}
</div>
{% if forloop.counter|divisibleby:3 %}
{% include "widgets/ad-unit-in-feed.html" %}
{% endif %}
{% if forloop.counter == 2 %}
{% include "partials/course_row_grid.html" with courses=courses %}
{% endif %}
{# {% if forloop.counter|divisibleby:3 %}#}
{# {% include "widgets/ad-unit-in-feed.html" %}#}
{# {% endif %}#}
{# {% if forloop.counter == 2 %}#}
{# {% include "partials/course_row_grid.html" with courses=courses %}#}
{# {% endif %}#}

{% endfor %}
{% include "partials/paging.html" with posts=posts %}
Expand Down
19 changes: 5 additions & 14 deletions bloggy/templates/pages/archive/quizzes.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base-with-header-footer.html" %}
{% load static %}
{#{% block base_css_class %}bg-white{% endblock base_css_class %}#}
{% spaceless %}
{% load custom_widgets %}
{% block content %}
Expand All @@ -20,22 +21,12 @@ <h1 class="display-1">
<div class="row row-cols-1 row-cols-md-3 row-cols-lg-4 g-4 gy-3">
{% for quiz in quizzes %}
<div class="col">
<div class="card article-card">
{% if quiz.thumbnail %}
<img src="{{ quiz.thumbnail.url }}" class="card-img-top" loading="lazy"
alt="{{ quiz.title }}">
{% endif %}
<div class="card-body p-3">
<div class="card article-card card-stack">
<div class="card-body card-body pb-0 px-3 pt-3">
<h3 class="article-title" style="font-size:1.1rem">
<a href="{% url 'quiz_single' slug=quiz.slug %}"
class="quiz-link">{{ quiz.title }}</a>
<a href="{% url 'quiz_single' slug=quiz.slug %}" class="quiz-link">{{ quiz.title }}</a>
</h3>
<p class="font-sm mb-1">{{ quiz.excerpt }}</p>
<p class="mt-3 mb-0">
<a href="{% url 'courses_single' slug=quiz.slug %}"
class="text-decoration-none text-primary fw-500 font-sm w-100">Start
Quiz&nbsp;&rarr;</a>
</p>
<p class="font-xs text-muted mb-1">{{ quiz.excerpt |slice:"0:80" }}..</p>
</div>

<div class="card-footer ">
Expand Down
3 changes: 2 additions & 1 deletion bloggy/templates/pages/home.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base-with-header-footer.html" %}
{% load custom_widgets %}
{#{% block base_css_class %}bg-white{% endblock base_css_class %}#}
{% spaceless %}
{% block content %}
{% load static %}
Expand All @@ -21,7 +22,7 @@ <h1 class="display-1 px-lg-5">

<section class="recent-articles py-3">
<div class="container">
<h2 class="mb-4 fw-600 ms-3">
<h2 class="mb-4 fw-600">
<span class="text-secondary">&blk14;</span> Recent <span class="text-gradient text-primary">tutorials</span>
</h2>

Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions bloggy/templates/pages/page-newsletter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office" lang="en">
{% block content %}
<div class="t204" style="margin: 1rem;background-color: #038bea;border: 2px solid #e6e6e682;overflow: hidden;text-align: center;line-height: 36px;border-radius: 8px 8px 8px 8px;position: absolute;padding: 0.07rem 1rem;">
<a class="t210" href="https://stacktips.com/"
style="display: block;margin: 0;font-family: 'Albert Sans', BlinkMacSystemFont,Segoe UI,Helvetica Neue,Arial,sans-serif !important;line-height: 36px;font-weight: 600;font-style: normal;font-size: 13px;text-decoration: none;direction: ltr;color: #fff;text-align: center;text-transform: uppercase;"
target="_blank">← Back to home</a>
</div>
{{ page.content |safe }}
{% endblock %}
30 changes: 16 additions & 14 deletions bloggy/templates/pages/single/course.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "base-with-header-footer.html" %}
{% load static %}
{% load custom_widgets %}
{% load define_action %}
{% spaceless %}
{% load custom_widgets %}
{% load define_action %}
{% block jsonld %}
{% include "seo/course_jsonld.html" %}
{% endblock jsonld %}
Expand Down Expand Up @@ -30,7 +30,7 @@
<div class="row">

<main id="main-content" class="hero col-12 col-md-8 col-lg-8 col-print-12 pe-lg-2">
<div class="article-details-card ms-md-3 mb-4 lessons_listl">
<div class="article-details-card p-5 ms-md-3 mb-4">


<div class="padding-medium relative pb-2">
Expand All @@ -44,13 +44,13 @@ <h1 class="post-title display-2 fw-600 mt-0 mb-2">{{ course.title }}</h1>
{{ lessons_list.count }} Lessons
</small>
<span class="meta-seperator"></span>
{% with course.category as category %}
<a class="text-decoration-none text-reset link-primary fw-bold"
style="z-index:999;position:relative"
href="{% url 'categories_single' slug=category.slug %}">
<small class="d-inline-block mb-1 text-primary text-uppercase fw-bold"
style="font-size:0.7rem;">{{ category.title }}</small>
</a>
{% with course.category as category %}
<a class="text-decoration-none text-reset link-primary fw-bold"
style="z-index:999;position:relative"
href="{% url 'categories_single' slug=category.slug %}">
<small class="d-inline-block mb-1 text-primary text-uppercase fw-bold"
style="font-size:0.7rem;">{{ category.title }}</small>
</a>
{% endwith %}
<span class="meta-seperator"></span>

Expand All @@ -62,19 +62,21 @@ <h1 class="post-title display-2 fw-600 mt-0 mb-2">{{ course.title }}</h1>
</div>
</div>
<div class="padding-medium relative pt-2">
{{ course.description |safe }}
<p>{{ course.description |safe }}</p>

<div class="container overflow-hidden">
<div class="row grid">

<div class="timeline-container p-4 mt-4">
<div class="timeline-container mt-4">
<div class="wrapper">
<ul class="sessions ">
{% for lesson in course.get_lessons %}
{% url 'lesson_single' course=course.slug slug=lesson.slug as current_url %}
<li class="list-group-item {% if request.get_full_path == current_url %}active{% endif %}">
<h3 class=""><a href="{% url 'lesson_single' course=course.slug slug=lesson.slug %}"
class="text-decoration-none h3 text-dark p-0 m-0 w-500">{{ lesson.title }}</a></h3>
<h3 class=""><a
href="{% url 'lesson_single' course=course.slug slug=lesson.slug %}"
class="text-decoration-none h3 text-dark p-0 m-0 w-500">{{ lesson.title }}</a>
</h3>
<p class="font-sm text-muted mb-3">{{ lesson.excerpt }}</p>
</li>
{% endfor %}
Expand Down
6 changes: 3 additions & 3 deletions bloggy/templates/pages/single/lesson.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{% spaceless %}
{% block content %}
{% include 'partials/home_lesson_breadcrumb.html' %}
<div class="container mt-lg-5 mt-md-3">
<div class="container mt-lg-4 mt-md-3">
<div class="row">
<main id="main-content" class="hero col-12 col-md-9 col-lg-9 col-print-12 pe-lg-2">
<div class="d-flex ">
Expand All @@ -25,8 +25,8 @@
</div>

<div class="flex-grow-1" style="overflow: hidden">
<div class="article-details-card mb-4 me-lg-3">
<div class="padding-medium relative">
<div class="article-details-card p-5 mb-4 me-lg-3">
<div class="relative">
<h1 class="display-2 fw-600"
style="line-height: 1.2;letter-spacing: -0.04rem">{{ post.title }}</h1>

Expand Down
Loading

0 comments on commit 948e4aa

Please sign in to comment.