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

add blog feature in django admin #15

Open
wants to merge 1 commit into
base: dev
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
8 changes: 8 additions & 0 deletions wazimap_np/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from .models import BlogEntry


@admin.register(BlogEntry)
class BlogEntryAdmin(admin.ModelAdmin):
ordering = ['-last_updated_on']
prepopulated_fields = {"slug": ("title",)}
11 changes: 11 additions & 0 deletions wazimap_np/blog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .models import BlogEntry
from django.views.generic import TemplateView


class BlogEntryView(TemplateView):
template_name = 'blog/blog_entry.html'

def get_context_data(self, *args, **kwargs):
return {
'blogs': BlogEntry.objects.all(),
}
25 changes: 25 additions & 0 deletions wazimap_np/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 2.2.6 on 2022-08-08 00:31

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='BlogEntry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_on', models.DateTimeField(auto_created=True)),
('title', models.CharField(max_length=200, unique=True)),
('slug', models.SlugField(max_length=255, unique=True)),
('description', models.TextField(default='enter content here...', verbose_name='content')),
('last_updated_on', models.DateTimeField(auto_now_add=True)),
],
),
]
Empty file.
12 changes: 12 additions & 0 deletions wazimap_np/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.db import models


class BlogEntry(models.Model):
title = models.CharField(max_length=200, null=False, blank=False, unique=True)
slug = models.SlugField(max_length=255, null=False, blank=False, unique=True)
description = models.TextField(default='enter content here...', verbose_name='content')
created_on = models.DateTimeField(auto_created=True)
last_updated_on = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.title
2 changes: 2 additions & 0 deletions wazimap_np/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
DATABASES['default'] = dj_database_url.parse(DATABASE_URL)
DATABASES['default']['ATOMIC_REQUESTS'] = True

USE_TZ = False

SCHEME = 'http' if (os.environ.get('APP_ENV', 'dev') == 'dev') else 'https'
URL = SCHEME+'://'+'nepalmap.org'

Expand Down
107 changes: 107 additions & 0 deletions wazimap_np/templates/blog/_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{% extends '_base.html' %}{% load staticfiles %}

{% block favicon %}
<link rel="shortcut icon" href="{{ STATIC_URL }}img/icons/favicon.ico" />
{% endblock favicon %}

{% block head_twitter_tags %}
{% if WAZIMAP.twittercard %}
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@codefornepal" />
<meta name="twitter:creator" content="@codefornepal" />
{% endif %}
{% endblock %}

{% block header %}
<header id="page-header">
<div id="page-header-title" class="wrapper clearfix">
{% if not hide_nav_tools %}
<i id="menu-toggle" class="fa fa-bars"></i>
{% endif %}
<a class="title" href="{% url 'homepage' %}">
{% block header_logo %}
{% endblock %}
{{ WAZIMAP.name }}
</a>
{% if not hide_nav_tools %}
{% block nav_tools %}
<div id="menu" class="tool-set clearfix">
<div class="tool-group">
<input name="geography_select" id="geography-select" type="text" placeholder="Start typing a place name or address..." autocomplete="off">
</div>
{% if not hide_nav_compare %}
{% comment %}
<span class="separator">or</span>
<div class="tool-group">
<a class="button" href="{% url 'table_search' %}">
<i class="fa fa-chevron-circle-right"></i>
Search for data
</a>
</div>
{% endcomment %}
{% endif %}
</div>
{% endblock %}
{% endif %}
<div class="header-buttons">

{% if WAZIMAP.facebook %}
<a href="https://facebook.com/{{ WAZIMAP.facebook }}" title="{{ WAZIMAP.facebook }} on Facebook" target="_blank"><i class="fa fa-2x fa-facebook-square"></i></a>
{% endif %}

{% if WAZIMAP.twitter %}
<a href="https://twitter.com/{{ WAZIMAP.twitter }}" title="{{ WAZIMAP.twitter }} on Twitter" target="_blank"><i class="fa fa-2x fa-twitter-square"></i></a>
{% endif %}

{% block header_branding %}
{% endblock %}
</div>
</div>
</header>
{% block header_content %}{% endblock header_content %}
{% endblock %}

{% block footer_content %}
<div class="column-quarter">
<ul class="ul-icon-list">
<li>
<i class="fa fa-info"></i> <a href="/about">About {{ WAZIMAP.name }}</a>
</li>
{% if WAZIMAP.twitter %}
<li>
<i class="fa fa-twitter"></i> <a href="http://twitter.com/{{ WAZIMAP.twitter }}" target="_blank">{{ WAZIMAP.twitter }}</a>
</li>
{% endif %}
</ul>

</div>
<div class="column-quarter">
<ul class="ul-icon-list">
<li>
<i class="fa fa-th-list"></i> <a href="http://www.codefornepal.org" target="_blank">Code For Nepal</a>
</li>
<li>
<i class="fa fa-envelope"></i> <a href="mailto:{{ WAZIMAP.email }}">Email us</a>
</li>
</ul>
</div>
<div class="column-quarter">
<ul class="ul-icon-list">
<li>
<i class="fa fa-github"></i> <a href="{{ WAZIMAP.github }}" target="_blank">NepalMap on Github</a>
</li>
<li>
<i class="fa fa-github"></i> Built on <a href="http://censusreporter.org" target="_blank">CensusReporter.org</a>
</li>
</ul>
</div>
<div class="column-quarter">
<ul class="ul-icon-list">
{% block footer_branding %}
<li>
<a href="http://www.codefornepal.org/" target="_blank"><img src="{% static 'img/codefornepal-logo-small.png' %}"></a>
</li>
{% endblock %}
</ul>
</div>
{% endblock footer_content %}
9 changes: 9 additions & 0 deletions wazimap_np/templates/blog/blog_entry.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'about.html' %}{% load partition staticfiles %}

{% block content %}
<article id="about" class="clearfix wrapper">
<header class="column-full">
<h1 class="article-header">{{ WAZIMAP.name }} Blog Detail</h1>
</header>
</article>
{% endblock %}
9 changes: 9 additions & 0 deletions wazimap_np/templates/blog/blog_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'about.html' %}{% load partition staticfiles %}

{% block content %}
<article id="about" class="clearfix wrapper">
<header class="column-full">
<h1 class="article-header">{{ WAZIMAP.name }} Blogs</h1>
</header>
</article>
{% endblock %}
10 changes: 10 additions & 0 deletions wazimap_np/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.conf.urls import url
from wazimap.urls import urlpatterns
from blog import BlogEntryView

urlpatterns += [
url(
regex="^blog$",
view=BlogEntryView.as_view()
),
]