[mezzanine-users] General search Admin interface

2015-08-07 Thread Diane N
Hello,

I'm trying to add a general search field(like a google search) in mezzanine 
admin interface. 
Do you have an idea how to do this?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Mezzanine (4.0) permissions - moderation

2015-08-07 Thread Déborah Leder
Hello again

I am coming back to my permission/moderation problem.
I finally understood the trick with super, and I am starting to have an 
idea about how to modify the queryset method.
There is another matter, though. I began to create a permission_app to 
create my moderation permission, in that app I created a directory called 
management in which I wrote a __init__.py fil containing this :
from django.db.models.signals import post_syncdb
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission

def add_moderation_permissions(sender, **kwargs):

This syncdb hooks takes care of adding a moderation permission too all 
our
content types.

# for each of our content types
for content_type in ContentType.objects.all():
# build our permission slug
codename = moderation_%s % content_type.model
# if it doesn't exist..
if not Permission.objects.filter(content_type=content_type, codename
=codename):
# add it
Permission.objects.create(content_type=content_type,
codename=codename,
name=Can moderation %s % content_type.name)
print Added moderation permission for %s % content_type.name
# check for all our moderation permissions after a syncdb
post_syncdb.connect(add_moderation_permissions)
It seems to have correctly added the permission, but only for the 
django_comments. I get that it's because it is the only ContentType, but 
the trick is that when I try to adapt the code for Page or BasePage, it 
doesn't work. I have a (completely normal) error that is raised : 
ValueError: Cannot query Blog: Must be ContentType instance.
(and it says blog only because it is the first model that is tried, but 
it must be the same for all the models).
I looked at the django/contrib/auth/models.py file to understand the type 
of Permission and Permission.objects, and it seems like everything was 
written to be contenttypes. I also looked at the Displayable, BasePage 
and Page types of mezzanine and it doesn't seem to inherit from ContentType 
in anyway... Besides, I would also want all of the objects I create in apps 
(I mean objects that inherit directly from models.Model) to recognise that 
permission.

So, how could I cleanly add my moderation permission for all the models 
that are in the apps I declared in INSTALLED_APPS and that can be editable 
in the admin interface, and not just content types ?

-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Modeltranslation failed after upgrade to Mezzanine 4.0

2015-08-07 Thread Ilya Yakunin
Hi!

I'm running a simple multilingual site under Mezzanine CMS. Everything was 
fine when I was using Mezzanine==3.1.10 and Django==1.6.8. But after 
upgrade to Mezzanine==4.0.1 and Django==1.8.3 I get an error when trying to 
run ./manage.py with any command.
The error is 
./manage.py 
update_translation_fields   
Traceback (most recent call 
last):  


  File manage.py, line 29, in 
module



execute_from_command_line(sys.argv) 


  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py,
 
line 338, in 
execute_from_command_line   



utility.execute()   


  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py,
 
line 312, in execute 

django.setup()  


  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/django/__init__.py,
 
line 18, in setup

apps.populate(settings.INSTALLED_APPS)  


  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/django/apps/registry.py,
 
line 115, in populate   

app_config.ready()  


  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/modeltranslation/apps.py,
 
line 11, in ready  

handle_translation_registrations()  


  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/modeltranslation/models.py,
 
line 81, in handle_translation_registrations
autodiscover()
  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/modeltranslation/models.py,
 
line 32, in autodiscover
import_module(module)
  File /usr/lib/python2.7/importlib/__init__.py, line 37, in import_module
__import__(name)
  File /home/elias/FIBREOPTIC/fibre_theme/translation.py, line 50, in 
module
translator.register(Page, PageTranslationOptions)
  File 
/home/elias/FIBREOPTIC/venv/local/lib/python2.7/site-packages/modeltranslation/translator.py,
 
line 399, in register
model.__name__)
modeltranslation.translator.AlreadyRegistered: Model Page is already 
registered for translation

i use standard Mezzanine models. My translation.py file is 

from modeltranslation.translator import translator, TranslationOptions
from mezzanine.pages.models import Page, RichTextPage, Link
from mezzanine.forms.models import Form, Field

class FormFieldTO(TranslationOptions):
fields = (
'label',
'default',
'placeholder_text',
'choices',
'placeholder_text',
'help_text',
)

class FormTO(TranslationOptions):
fields = (
'response',
'content',
'button_text',
)

class PageTranslationOptions(TranslationOptions):
fields = (
'title',
# 'description',
)
required_languages = (
'ru',
)

class RichPageTranslationOptions(TranslationOptions):
fields = (
'content',
)
required_languages = (
'ru',
)

class LinkTranslationOptions(TranslationOptions):
pass

translator.register(Page, PageTranslationOptions)
translator.register(RichTextPage, RichPageTranslationOptions)
translator.register(Form, FormTO)
translator.register(Link, LinkTranslationOptions)
translator.register(Field, FormFieldTO)

Using a trick from 
http://mezzanine.jupo.org/docs/multi-lingual-sites.html#translation-fields-and-migrations
 
won't help. After switching to USE_MODELTRANSLATION = False and running 

python manage.py makemigrations

I get an error:

modeltranslation.translator.NotRegistered: The model Page is not 
registered for translation

Lines from settings.py related to mulilingual support are:

LANGUAGES = (
('ru', gettext('Russian')),
('en', gettext('English')),
)

USE_MODELTRANSLATION = True
MODELTRANSLATION_DEFAULT_LANGUAGE = 'ru'

...
INSTALLED_APPS = (
#south,
modeltranslation,
django.contrib.admin,
django.contrib.auth,
django.contrib.contenttypes,
django.contrib.redirects,
django.contrib.sessions,
django.contrib.sites,
django.contrib.sitemaps,
django.contrib.staticfiles,
mezzanine.boot,