remotes/origin/search
Alexander Burdeiny 10 years ago
parent 04ba938b7b
commit 7c94bf4ef6
  1. 6
      article/forms.py
  2. 1
      article/models.py
  3. 20
      templates/admin/article/article_admin_list.html
  4. 19
      templates/admin/article/blog_form.html
  5. 43
      theme/admin.py

@ -46,7 +46,7 @@ class BlogForm(forms.Form):
self.fields['descriptions_%s' % code] = forms.CharField(label='Дескрипшен', required=False, max_length=255, self.fields['descriptions_%s' % code] = forms.CharField(label='Дескрипшен', required=False, max_length=255,
widget=forms.TextInput(attrs={'style':'width: 550px'})) widget=forms.TextInput(attrs={'style':'width: 550px'}))
def save(self, author, article=None): def save(self, author, article=None, commit=True):
data = self.cleaned_data data = self.cleaned_data
# create new Article object or get exists # create new Article object or get exists
if not article: if not article:
@ -77,8 +77,8 @@ class BlogForm(forms.Form):
#for item in data['tag']: #for item in data['tag']:
# article.tag.add(item) # article.tag.add(item)
article.save() if commit == True:
article.save()
return article return article
def clean_tag(self): def clean_tag(self):

@ -59,6 +59,7 @@ class Article(TranslatableModel):
"set a custom description."), default=False) "set a custom description."), default=False)
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True) modified = models.DateTimeField(auto_now=True)
draft = models.BooleanField(_(u'Черновик'), default=False, db_index=True)
#translated fields #translated fields
translations = TranslatedFields( translations = TranslatedFields(

@ -1,20 +1,22 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load i18n %}
{% block body %} {% block body %}
<div class="box span8"> <div class="box span8">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-arrow-down"></i>Список статей</h2> <h2><i class="icon-arrow-down"></i>{% trans "Список статей" %}</h2>
</div> </div>
<div class="box-content"> <div class="box-content">
<form class='form-search'> <form class='form-search'>
{{ search_form.search_name }} {{ search_form.search_name }}
<button type="submit" class="btn">Найти</button> <button type="submit" class="btn">{% trans "Найти" %}</button>
</form> </form>
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<th>Заголовок</th> <th>{% trans "Заголовок" %}</th>
<th>Автор</th> <th>{% trans "Автор" %}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
</thead> </thead>
@ -26,19 +28,19 @@
<td>{% ifnotequal item.author None %}{{ item.author }} {% endifnotequal %}</td> <td>{% ifnotequal item.author None %}{{ item.author }} {% endifnotequal %}</td>
<td class="center sorting_1"> <td class="center sorting_1">
<a class="btn-small btn-info" href="{{ item.admin_url }}"> <a class="btn-small btn-info" href="{{ item.admin_url }}">
Изменить {% trans "Изменить" %}
</a> </a>
</td> </td>
<td class="center sorting_1"> <td class="center sorting_1">
<a class="btn-small btn-inverse" href="/admin/article/copy/{{ item.slug|lower }}"> <a class="btn-small btn-inverse" href="/admin/article/copy/{{ item.slug|lower }}">
Копировать {% trans "Копировать" %}
</a> </a>
</td> </td>
<td> <td>
<a class="btn-small btn-danger delete" href="/admin/article/delete/{{ item.slug }}/"> <a class="btn-small btn-danger delete" href="/admin/article/delete/{{ item.slug }}/">
Удалить {% trans "Удалить" %}
</a> </a>
</td> </td>
</tr> </tr>
@ -46,8 +48,8 @@
</tbody> </tbody>
</table> </table>
<a class="btn btn-success" href="{% if blog_flag %}/admin/article/blog/{% else %}{% if news_flag %}/admin/article/news/{% endif %}{% endif %}"> <a class="btn btn-success" href="{% if blog_flag %}/admin/article/blog/{% else %}{% if news_flag %}/admin/article/news/{% endif %}{% endif %}">
<i class="icon-plus-sign icon-white"></i> Добавить <i class="icon-plus-sign icon-white"></i> {% trans "Добавить" %}
{% if blog_flag %}статью{% else %}{% if news_flag %}новость{% endif %}{% endif %} {% if blog_flag %}{% trans "статью" %}{% else %}{% if news_flag %}{% trans "новость" %}{% endif %}{% endif %}
</a> </a>
</div> </div>

@ -1,5 +1,6 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% load static %} {% load static %}
{% load i18n %}
{# Displays article form #} {# Displays article form #}
{% block scripts %} {% block scripts %}
@ -34,11 +35,11 @@
{{ form.errors }} {{ form.errors }}
<form method="post" class="form-horizontal" name="form2" id="form2"enctype="multipart/form-data"> {% csrf_token %} <form method="post" class="form-horizontal" name="form2" id="form2"enctype="multipart/form-data"> {% csrf_token %}
<fieldset> <fieldset>
<legend><i class="icon-edit"></i>{% if article %} Изменить {% else %} Добавить {% endif %}статью{% if article %}(<a href="{{ article.get_permanent_url }}" target="_blank">на сайте</a>){% endif %}</legend> <legend><i class="icon-edit"></i>{% if article %} {% trans "Изменить" %} {% else %} {% trans "Добавить" %} {% endif %}{% trans "статью" %}{% if article %}(<a href="{{ article.get_permanent_url }}" target="_blank">{% trans "на сайте" %}</a>){% endif %}</legend>
<div class="box span8"> <div class="box span8">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-pencil"></i> Основная информация</h2> <h2><i class="icon-pencil"></i> {% trans "Основная информация" %}</h2>
</div> </div>
<div class="box-content"> <div class="box-content">
@ -124,14 +125,14 @@
</div> </div>
<div class="box span8" id="file"> <div class="box span8" id="file">
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-pencil"></i> Файлы</h2> <h2><i class="icon-pencil"></i> {% trans "Файлы" %}</h2>
</div> </div>
<div class="box-content"> <div class="box-content">
{% if article %} {% if article %}
{# button that shows modal window with file form #} {# button that shows modal window with file form #}
<a href="#myModal" id="file_add" role="button" class="btn btn-info" data-toggle="modal">Добавить файл</a> <a href="#myModal" id="file_add" role="button" class="btn btn-info" data-toggle="modal">{% trans "Добавить файл" %}</a>
{% else %} {% else %}
<p>Файлы можно добавлять только после введения основных данных</p> <p>{% trans "Файлы можно добавлять только после введения основных данных" %}</p>
{% endif %} {% endif %}
{# this div shows list of files and refreshes when new file added #} {# this div shows list of files and refreshes when new file added #}
<div id="file_list"> <div id="file_list">
@ -139,10 +140,10 @@
<thead> <thead>
<tr> <tr>
<td>id</td> <td>{% trans "id" %}</td>
<td>Файл</td> <td>{% trans "Файл" %}</td>
<td>Имя</td> <td>{% trans "Имя" %}</td>
<td>Назначение</td> <td>{% trans "Назначение" %}</td>
<td></td> <td></td>
</tr> </tr>
</thead> </thead>

@ -1,17 +1,34 @@
# -*- coding: utf-8 -*- #custom views
from django.shortcuts import render_to_response import json
from django.http import HttpResponseRedirect, HttpResponse
from django.core.context_processors import csrf
from django.conf import settings from django.conf import settings
from django.views.generic import CreateView, UpdateView, DeleteView
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse_lazy
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.views.generic import CreateView, DeleteView, UpdateView
# -*- coding: utf-8 -*-
#forms and models #forms and models
from forms import ThemeForm, TagForm, ThemeDeleteForm, TagDeleteForm, TagFilterForm, ThemeFilterForm from forms import (
from models import Theme, Tag, ThemeBlog TagDeleteForm,
#custom views TagFilterForm,
from functions.custom_views import objects_list, add_object, delete_object, ListView TagForm,
from functions.views_help import get_referer ThemeDeleteForm,
ThemeFilterForm,
ThemeForm
)
from functions.admin_views import AdminListView from functions.admin_views import AdminListView
from functions.custom_views import (
ListView,
add_object,
delete_object,
objects_list
)
from functions.views_help import get_referer
from .forms import ThemeBlogForm
from .models import Tag, Theme, ThemeBlog
def theme_all(request): def theme_all(request):
@ -131,8 +148,6 @@ def tag_change(request, tag_id=None):
return render_to_response('tag_add.html', args) return render_to_response('tag_add.html', args)
from django.http import HttpResponse
import json
def search_tag(request): def search_tag(request):
theme = request.GET['theme'] theme = request.GET['theme']
@ -149,6 +164,7 @@ def search_tag(request):
return HttpResponse(json.dumps(tags), content_type='application/json') return HttpResponse(json.dumps(tags), content_type='application/json')
def search2(request): def search2(request):
term = request.GET['term'] term = request.GET['term']
if not term: if not term:
@ -171,9 +187,6 @@ class TagListView(AdminListView):
model = Tag model = Tag
from functions.custom_views import ListView
from django.core.urlresolvers import reverse_lazy
from .forms import ThemeBlogForm
class ThemeBlogListView(ListView): class ThemeBlogListView(ListView):

Loading…
Cancel
Save