Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make actions for model

  • Loading branch information...
commit 80268d24172ec44428bce941af5c4514c5ef1b42 1 parent 2ff6883
@d1ffuz0r authored
View
21 lulz/admin.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.auth.models import Group
from models import Category, Comments, Job, Likes, Image
@@ -9,7 +10,25 @@ class AdminImages(admin.ModelAdmin):
class AdminJobs(admin.ModelAdmin):
list_display = ("name", "category", "published", "date")
-
+ actions = ["publish", "unpublish"]
+
+ def publish(self, request, queryset):
+ public = queryset.update(published=True)
+ if public == 1:
+ message_bit = u"1 вакансия была опубликована"
+ else:
+ message_bit = u"%s вакансии были опубликованы" % rows_updated
+ self.message_user(request, "%s" % message_bit)
+ publish.short_description = u"Опубликовать выбраные Вакансии"
+
+ def unpublish(self, request, queryset):
+ ubpub = queryset.update(published=False)
+ if ubpub == 1:
+ message_bit = u"1 вакансия был убрана"
+ else:
+ message_bit = u"%s вакансии были убраны" % rows_updated
+ self.message_user(request, "%s из опубликованых" % message_bit)
+ unpublish.short_description = u"Убрать из опубликованых"
class AdminCategory(admin.ModelAdmin):
list_display = ("name",)
View
22 lulz/models.py
@@ -5,7 +5,7 @@
class Image(models.Model):
name = models.CharField(max_length=100,
verbose_name=u"Название")
- image = models.ImageField(upload_to='backgrounds',
+ image = models.ImageField(upload_to="backgrounds",
verbose_name=u"Фон")
class Meta:
@@ -38,18 +38,18 @@ class Job(models.Model):
desc = models.TextField(max_length=1000,
verbose_name=u"Комментарий")
tags = models.CharField(max_length=100,
- verbose_name=u"Ключевые слова")
+ verbose_name=u"Теги")
likes = models.IntegerField(verbose_name=u"Лайки", default=0)
link = models.URLField(max_length=100,
- verbose_name=u"Ссылка на оригинал")
+ verbose_name=u"Ссылка на оригинал")
published = models.BooleanField(default=False,
verbose_name=u"Опубликовано")
date = models.DateTimeField(auto_now=True,
verbose_name=u"Дата публикации")
category = models.ForeignKey(Category,
verbose_name=u"Категория")
- comments = models.ManyToManyField('Comments',
- related_name='jobcomm',
+ comments = models.ManyToManyField("Comments",
+ related_name="jobcomm",
blank=True,
verbose_name=u"Комментарии")
@@ -65,7 +65,7 @@ class Comments(models.Model):
text = models.CharField(max_length=200,
verbose_name=u"Текст комментария")
job = models.ForeignKey(Job,
- related_name='jobcomm',
+ related_name="jobcomm",
verbose_name=u"Вакансия")
agent = models.CharField(max_length=200, verbose_name=u"User-Agent")
ip = models.CharField(max_length=100, verbose_name=u"IP")
@@ -75,16 +75,16 @@ class Meta:
verbose_name_plural = u"Комментарии"
def __unicode__(self):
- return '%s/%s' % (self.text[:10], self.job.name)
+ return "%s/%s" % (self.text[:10], self.job.name)
class Likes(models.Model):
CHOISES = (
- ('1', '+'),
- ('0', '-')
+ ("1", "+"),
+ ("0", "-")
)
job = models.ForeignKey(Job,
- related_name='joblikes',
+ related_name="joblikes",
verbose_name=u"Вакансия")
agent = models.CharField(max_length=200, verbose_name=u"User-Agent")
ip = models.CharField(max_length=100, verbose_name=u"IP")
@@ -95,4 +95,4 @@ class Meta:
verbose_name_plural = u"Лайки"
def __unicode__(self):
- return '%s/%s' % (self.job.name, self.type)
+ return "%s/%s" % (self.job.name, self.type)
View
6 public/static/js/lol.js
@@ -118,7 +118,8 @@ $(document).ready(function()
$(".bg").css('background-image','');
});
- $("#addvacancy").validate({
+ $("#addvacancy").validate(
+ {
onkeyup: false,
onblur : false,
submitHandler: function()
@@ -138,7 +139,8 @@ $(document).ready(function()
}
});
- $("#addcomment").validate({
+ $("#addcomment").validate(
+ {
onkeyup: false,
onblur : false,
submitHandler: function()
View
1  public/templates/jobs.html
@@ -66,6 +66,7 @@ <h2 id="slogan" title="Наркоманы штоле?">Самые ёбнутые
<div id="content-wrap">
<div id="sidebar">
<img src="{{ STATIC_URL }}images/1306311362719.png" alt="WTF">
+ <h1>Всего опубликовано: {{ count }}</h1>
</div>
<div id="main">
{% if jobs %}
Please sign in to comment.
Something went wrong with that request. Please try again.