gadjo theme used for templates

Category and announces management views and urls updated
This commit is contained in:
Serghei Mihai 2015-01-15 10:34:45 +01:00
parent 36e2db0b1c
commit cc12ccfe0a
11 changed files with 148 additions and 70 deletions

View File

@ -10,6 +10,8 @@ urlpatterns = patterns('',
name='edit_announce'),
url(r'^announce/delete/(?P<pk>\d+)$', delete_announce,
name='delete_announce'),
url(r'^category/add$', add_category,
name='add_category'),
url(r'^category/edit/(?P<pk>\d+)$', edit_category,
name='edit_category'),
url(r'^category/delete/(?P<pk>\d+)$', delete_category,

View File

@ -10,8 +10,10 @@ https://docs.djangoproject.com/en/1.7/ref/settings/
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
from django.conf import global_settings
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
@ -32,6 +34,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = (
'corbo',
'ckeditor',
'gadjo',
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
@ -78,18 +81,22 @@ USE_L10N = True
USE_TZ = True
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + ('gadjo.finders.XStaticFinder',)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
CKEDITOR_UPLOAD_PATH = 'ckeditor/uploads'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
ANNOUNCES_PER_PAGE = 10
ANNOUNCES_PER_PAGE = 3
RSS_TITLE = 'Announces'
RSS_DESCRIPTION = ''

View File

@ -15,6 +15,11 @@ body {
margin: 0;
}
a:link, a:visited, a:hover {
text-decoration: none;
color: #000;
}
header h1 {
padding: 5px 10px;
border-bottom: 1px solid #000;
@ -37,17 +42,17 @@ ul.announces {
padding: 0;
}
ul.announces li, ul.auth li, ul#management li {
ul.announces li, ul.auth li, #management ul li {
list-style-type: none;
padding: .1em .5em;
}
ul.announces li.bright {
li.bright {
background: #fff;
}
ul.announces li.grey {
background: #eee;
li.bluesky {
background: #d3d8e8 !important;
}
div.pub_time {
@ -60,14 +65,14 @@ div.clear {
}
ul.pagination {
font-size: .8>em;
font-size: .8em;
margin: 0;
padding: 0;
}
ul.pagination li {
list-style-type: none;
#management ul.pagination li {
display: inline;
margin: 0 2px;
}
ul.pagination li.current {
@ -130,21 +135,31 @@ ul.auth button {
div.user {
font-weight: bold;
font-size: .9em;
float: right;
margin: 0 10px;
padding: 3px;
border: 1px solid #ccc;
border: 1px solid #777;
border-top: 0;
border-radius: 0 0 .3em .3em;
background: #aaa;
background: #ddd;
}
ul#management {
div.user a.logout:before {
content: '\f08b';
margin-left: .4em;
}
#management {
margin: 1em 0 .5em 0;
}
#management ul {
margin: 1em 0 0 0;
padding: 0;
}
ul#management li {
#management ul li {
padding: 5px;
border: 1px solid #aaa;
background: #eee;
@ -153,6 +168,10 @@ ul#management li {
position: relative;
}
#management h4 {
margin: .4em 0;
}
.title {
font-size: .9em;
font-weight: bold;
@ -208,4 +227,28 @@ ul#management li {
width: 20em;
color: #aaa;
margin: 0 auto;
}
.categories {
float: right;
}
.categories select {
border: 1px solid #aaa;
display: inline;
}
.categories a, #management > span a {
color: #000;
border: 1px solid #666;
padding: 1px 3px;
margin: 0;
font-weight: bold;
font-size: .75em;
background: #eee;
}
a.add:before {
content: '\f067';
padding-right:3px;
}

View File

@ -1,29 +0,0 @@
{% load i18n static %}
<html>
<head>
<title>Corbo :: {% block title %}{%trans "Announces" %}{% endblock %}</title>
<link rel='stylesheet' type='text/css' href='{% static "css/corbo.css" %}' />
{% block scripts %}
{% endblock %}
</head>
<body>
<header>
{% if user.is_authenticated %}
<div class="user">
{% trans "Welcome" %} {{ user.get_full_name }}
<a href="{% url "logout" %}">{% trans "Logout" %}</a>
</div>
{% endif %}
<h1>{% trans "Announces" %}</h1>
</header>
<div id="content">
{% block content %}
{% endblock %}
</div>
<footer>
Powered by Corbo. &copy 2015 Entr'ouvert
</footer>
{% block extrascripts %}
{% endblock %}
</body>
</html>

View File

@ -0,0 +1,10 @@
{% extends "corbo/manage.html" %}
{% load i18n %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.media }}
{{ form.as_p }}
<button>{% trans "Save" %}</button>
</form>
{% endblock %}

View File

@ -0,0 +1,23 @@
{% extends "gadjo/base.html" %}
{% load i18n static %}
{% block page-title %}{% trans "Corbo" %}{% endblock %}
{% block css %}
<link rel='stylesheet' type='text/css' href='{% static "css/corbo.css" %}' />
{% endblock %}
{% block logout-url %}
{% url "logout" %}
{% endblock %}
{% block site-title %} {% trans "Announces" %}{% endblock %}
{% block more-user-links %}
{{ block.super }}
{% if user.is_authenticated and user.is_superuser %}
<a href="{% url 'manage' %}">{% trans "Management" %}</a>
{% endif %}
{% endblock %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends "corbo/manage.html" %}
{% load i18n %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button>{% trans "Save" %}</button>
</form>
{% endblock %}

View File

@ -1,10 +1,10 @@
{% extends 'base.html' %}
{% extends 'corbo/base.html' %}
{% load i18n %}
{% block content %}
<ul class="announces">
{% for object in object_list %}
<li class="{% cycle 'bright' 'grey' %}">
<li class="{% cycle 'bright' 'bluesky' %}">
<h2>{{ object.title }}</h2>
<div class="text">
{{ object.text|safe }}

View File

@ -1,16 +1,13 @@
{% extends 'base.html' %}
{% extends 'corbo/base.html' %}
{% load i18n static %}
{% block title %}{% trans "Management" %}{% endblock %}
{% block scripts %}
<script type="text/javascript" src="{% static "js/jquery-1.11.2.min.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "js/corbo.js" %}"></script>
{% block page-title %}
{{ block.super }} :: {% trans "Management" %}
{% endblock %}
{% block content %}
<div class="category">
<div class="categories">
<span class="title">{% trans "Category:" %}</span>
<select>
<option value=''>{% trans "All" %}</option>
@ -18,24 +15,29 @@
<option value='{{ category.id }}'{% if category_id == category.id %} selected{% endif %}>{{ category }}</option>
{% endfor %}
</select>
<span><a class="icon add" href="{% url "add_category" %}" rel="popup">{% trans "add category" %}</a></span>
</div>
<ul id="management">
<div id="management">
<h4>{% trans "Announces" %}</h4>
<span><a class="icon add" href="{% url "add_announce" %}" rel="popup">{% trans "add announce" %}</a></span>
<ul>
{% for obj in object_list %}
<li>
<li class='{% cycle 'bluesky' '' %}'>
<div class="status">
{% if obj.is_published %}
<span class="icon published" title="{% trans "published" %}"></span>
{% endif %}
{% if not obj.is_published %}
{% if obj.is_expired %}
<span class="icon expired" title="{% trans "expired" %}"></span>
{% endif %}
{% if obj.is_not_published %}
{% else %}
<span class="icon unpublished" title="{% trans "not published yet" %}"></span>
{% endif %}
{% endif %}
</div>
<div class="actions">
<span class="icon edit"><a href="#"></a></span>
<span class="icon delete"><a href="#"></a></span>
<span><a class="icon edit" href="{% url 'edit_announce' obj.id %}" rel="popup"></a></span>
<span><a class="icon delete" href="{% url 'delete_announce' obj.id %}" rel="popup"></a></span>
</div>
<div class="announce">
<div class="title">{{ obj.title }}</div>
@ -66,11 +68,13 @@
{% endif %}
</ul>
{% endif %}
</div>
{% endblock %}
{% block extrascripts %}
{% block page-end %}
<script type="text/javascript">
$(function() {
$('div.category select').on('change', function() {
$('div.categories select').on('change', function() {
var category = $(this).val();
if (category)
window.location.replace('{% url "manage" %}?category=' + category);

View File

@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% extends 'corbo/base.html' %}
{% load i18n %}
{% block title %}{% trans "Login" %}{% endblock %}
{% block page-title %}{{ block.super }} :: {% trans "Login" %}{% endblock %}
{% block content %}
<form method="post">
<ul class="auth">

View File

@ -7,39 +7,48 @@ from django.views.generic.list import MultipleObjectMixin
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Atom1Feed
import models
from .forms import AnnounceForm, CategoryForm
class HomepageView(ListView):
model = models.Announce
template_name = 'homepage.html'
template_name = 'corbo/homepage.html'
homepage = HomepageView.as_view()
class AnnounceCreateView(CreateView):
model = models.Announce
form_class = AnnounceForm
template_name = 'corbo/announce_form.html'
success_url = '..'
add_announce = AnnounceCreateView.as_view()
class AnnounceEditView(UpdateView):
model = models.Announce
success_url = '../..'
edit_announce = AnnounceEditView.as_view()
class AnnounceDeleteView(DeleteView):
success_url = '../..'
model = models.Announce
delete_announce = AnnounceDeleteView.as_view()
edit_announce = AnnounceEditView.as_view()
class CategoryCreateView(CreateView):
model = models.Category
form_class = CategoryForm
template_name = 'corbo/category_form.html'
success_url = '..'
def form_valid(self, form):
form.save()
return super(CategoryCreateView, self).form_valid(form)
add_category = CategoryCreateView.as_view()
class CategoryEditView(UpdateView):
model = models.Category
success_url = '..'
edit_category = CategoryEditView.as_view()
@ -51,7 +60,7 @@ delete_category = DeleteView.as_view()
class ManageView(ListView, MultipleObjectMixin):
paginate_by = settings.ANNOUNCES_PER_PAGE
template_name = 'manage.html'
template_name = 'corbo/manage.html'
model = models.Announce
def get_queryset(self):