Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created April 6, 2010 15:48
Show Gist options
  • Save vbmendes/357740 to your computer and use it in GitHub Desktop.
Save vbmendes/357740 to your computer and use it in GitHub Desktop.
...
class AdminInscricao(ProjectModelAdmin):
list_display = ('email', 'nome', 'inscrito', 'admin_grupos', 'data_de_criacao', )
search_fields = ('email', 'nome')
list_filter = ('inscrito', 'grupos')
actions = ('subscribe_action', 'unsubscribe_action')
def admin_grupos(self, obj):
return '<br />'.join([unicode(obj) for obj in obj.grupos.all()])
admin_grupos.short_description = u'grupos'
admin_grupos.allow_tags = True
def subscribe_action(self, request, queryset):
queryset.update(inscrito=True)
request.user.message_set.create(message=u"Inscrições realizadas com sucesso.")
subscribe_action.short_description = u'Inscrever'
def unsubscribe_action(self, request, queryset):
queryset.update(inscrito=False)
request.user.message_set.create(message=u"Desinscrições realizadas com sucesso.")
unsubscribe_action.short_description = u'Desinscrever'
...
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
#: django/contrib/admin/actions.py:85
#, python-format
msgid "Delete selected %(verbose_name_plural)s"
msgstr "Excluir %(verbose_name_plural)s selecionados(as)"
#, python-format
msgid "Atuacoes_Parlamentares"
msgstr "Atuações parlamentares"
#, python-format
msgid "Noticias"
msgstr "Notícias"
#, python-format
msgid "Videos"
msgstr "Vídeos"
#, python-format
msgid "Auth"
msgstr "Autenticação"
Traceback (most recent call last):
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/core/handlers/base.py", line 92, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/contrib/admin/options.py", line 226, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/contrib/admin/sites.py", line 186, in inner
return view(request, *args, **kwargs)
File "/home/sinmedrn1/wsgi_apps/coopmedrn/project/code/src/meio/common/admin/options.py", line 78, in changelist_view
return super(ExtraButtonsModelAdmin, self).changelist_view(request, extra_context)
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/contrib/admin/options.py", line 885, in changelist_view
actions = self.get_actions(request)
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/contrib/admin/options.py", line 464, in get_actions
actions.sort(lambda a,b: cmp(a[2].lower(), b[2].lower()))
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/contrib/admin/options.py", line 464, in <lambda>
actions.sort(lambda a,b: cmp(a[2].lower(), b[2].lower()))
File "/home/sinmedrn1/wsgi_apps/coopmedrn/lib/python2.6/site-packages/django/utils/functional.py", line 192, in __wrapper__
raise TypeError("Lazy object returned unexpected type.")
TypeError: Lazy object returned unexpected type.
<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'sessionid': '1856a87b9e9512b1bda808d1e4e8487a'},
META:{'DOCUMENT_ROOT': '/home/sinmedrn1/public_html/coopmedrn',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
'HTTP_ACCEPT_LANGUAGE': 'pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4',
'HTTP_CONNECTION': 'keep-alive',
'HTTP_COOKIE': 'sessionid=1856a87b9e9512b1bda808d1e4e8487a',
'HTTP_HOST': 'coopmedrn.org.br',
'HTTP_REFERER': 'http://coopmedrn.org.br/admin/newsletter/',
'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.7 Safari/533.2',
'LOG_SUBDIR': 'sinmedrn1',
'PATH': '/sbin:/usr/sbin:/bin:/usr/bin',
'PATH_INFO': u'/admin/newsletter/inscricao/',
'PATH_TRANSLATED': 'redirect:/index.wsgi/admin/newsletter/inscricao//newsletter/inscricao/',
'QUERY_STRING': '',
'REDIRECT_LOG_SUBDIR': 'sinmedrn1',
'REDIRECT_SCRIPT_URI': 'http://coopmedrn.org.br/admin/newsletter/inscricao/',
'REDIRECT_SCRIPT_URL': '/admin/newsletter/inscricao/',
'REDIRECT_STATUS': '200',
'REDIRECT_UNIQUE_ID': 'S7tU6MjqyHwAAAw0xCIAAAB1',
'REDIRECT_URL': '/admin/newsletter/inscricao/',
'REMOTE_ADDR': '187.40.243.210',
'REMOTE_PORT': '54895',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/admin/newsletter/inscricao/',
'SCRIPT_FILENAME': '/home/sinmedrn1/public_html/coopmedrn/index.wsgi',
'SCRIPT_NAME': u'',
'SCRIPT_URI': 'http://coopmedrn.org.br/admin/newsletter/inscricao/',
'SCRIPT_URL': '/admin/newsletter/inscricao/',
'SERVER_ADDR': '200.234.200.124',
'SERVER_ADMIN': '[email protected]',
'SERVER_NAME': 'coopmedrn.org.br',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '',
'SERVER_SOFTWARE': 'Apache/2.2.14 (Locaweb)',
'UNIQUE_ID': 'S7tU6MjqyHwAAAw0xCIAAAB1',
'mod_wsgi.application_group': 'coopmedrn.org.br|/index.wsgi',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.listener_host': '0.0.0.0',
'mod_wsgi.listener_port': '80',
'mod_wsgi.process_group': '265815370215-coopmedrn.org.br',
'mod_wsgi.reload_mechanism': '1',
'mod_wsgi.script_reloading': '1',
'wsgi.errors': <mod_wsgi.Log object at 0x44a1c3f8>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x417f39f8>,
'wsgi.input': <mod_wsgi.Input object at 0x4561dca0>,
'wsgi.multiprocess': False,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment