Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Brandon Keith Biggs

Hello,
I can't get this method to work. Here is what I have:
my_app/script_module.py
from mezzanine import template
register = template.Library()

@register.as_tag
def test_text():
return Hello world


my_theme/templates/index.html
{% extends base.html %}
{% load i18n %}
{% test_text %}

I get the error:
TemplateSyntaxError at /
Invalid block tag: 'test_text'

I then try adding in index.html:

{% extends base.html %}
{% load i18n %}
{% load my_app %}
{% test_text %}

But then get:
TemplateSyntaxError at /
'my_app' is not a valid tag library:

So then when I put
script_module.py
into
my_app/templatetags/my_script.py
I still get the same error.
thanks,

Brandon Keith Biggs http://www.brandonkeithbiggs.com/
On 7/16/2015 1:18 AM, Eduardo Rivas wrote:
That should work without issue, though I generally like to bundle all 
the as tags on top of the block.


{% block main %}
{% get_sitewide_content as sitewide %}
h1my text/h1
{{ sitewide.foobar }}
{% endblock %}

Also, be careful with the blocktrans tag, you need to explicitly bind 
any variable you want to use inside them. You should also avoid 
including HTML tags inside them to prevent poluting the gettext 
catalog with markup 
https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#blocktrans-template-tag.




--
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Stephen McDonald
You're probably missing an empty __init__.py file:

https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/#code-layout

On Thu, Jul 16, 2015 at 12:00 PM, Brandon Keith Biggs 
brandonkeithbi...@gmail.com wrote:

  Hello,
 I can't get this method to work. Here is what I have:
 my_app/script_module.py
 from mezzanine import template
 register = template.Library()

 @register.as_tag
 def test_text():
 return Hello world


 my_theme/templates/index.html
 {% extends base.html %}
 {% load i18n %}
 {% test_text %}

 I get the error:
 TemplateSyntaxError at /
 Invalid block tag: 'test_text'

 I then try adding in index.html:

 {% extends base.html %}
 {% load i18n %}
 {% load my_app %}
 {% test_text %}

 But then get:
 TemplateSyntaxError at /
 'my_app' is not a valid tag library:

 So then when I put
 script_module.py
 into
 my_app/templatetags/my_script.py
 I still get the same error.
 thanks,

  Brandon Keith Biggs http://www.brandonkeithbiggs.com/
 On 7/16/2015 1:18 AM, Eduardo Rivas wrote:

 That should work without issue, though I generally like to bundle all the
 as tags on top of the block.

 {% block main %}
 {% get_sitewide_content as sitewide %}
 h1my text/h1
 {{ sitewide.foobar }}
 {% endblock %}

 Also, be careful with the blocktrans tag, you need to explicitly bind any
 variable you want to use inside them. You should also avoid including HTML
 tags inside them to prevent poluting the gettext catalog with markup
 https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#blocktrans-template-tag
 .


  --
 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.




-- 
Stephen McDonald
http://jupo.org

-- 
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Brandon Keith Biggs

Hello,
How do you call the function in a block? Because for my index I have:
{% block main %}
{% blocktrans %}
h1my text/h1
{% where I want the function %}
{{ where I want the variable }}
{% endblocktrans %}
{% endblock %}

Thanks,

Brandon Keith Biggs http://www.brandonkeithbiggs.com/
On 7/16/2015 12:23 AM, Eduardo Rivas wrote:
As an alternative, you can also use SingletonAdmin and a template tag 
to make model data available anywhere in the site. Josh wrote about it 
and I follow this pattern all the time: 
http://bitofpixels.com/blog/on-singletonadmins-and-sitewidecontent-editing-sitewide-content-in-mezzanines-admin/.




--
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 is released

2015-07-15 Thread Neum Schmickrath
I should be able to take on the update of the changelog to a manual format. 
Did you want it in Restructured text format in the Docs? How would you like 
each change listed? Can you give me a brief example I can work from?

 

-- 
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Eduardo Rivas
That should work without issue, though I generally like to bundle all 
the as tags on top of the block.


{% block main %}
{% get_sitewide_content as sitewide %}
h1my text/h1
{{ sitewide.foobar }}
{% endblock %}

Also, be careful with the blocktrans tag, you need to explicitly bind 
any variable you want to use inside them. You should also avoid 
including HTML tags inside them to prevent poluting the gettext catalog 
with markup 
https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#blocktrans-template-tag.


--
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Brandon Keith Biggs

Hello,
I think I did this exactly how you said, but in my index.html nothing 
shows up. Here is what I have:

my_app/defaults.py

from mezzanine.conf import register_setting

register_setting(name='test_text', default=Hello world)
register_setting(name=TEMPLATE_ACCESSIBLE_SETTINGS, append=True, 
default=(test_text,))



my_theme/templates/index.html

{% extends base.html %}
... all defaults
{% block main %}
{% blocktrans %}
h2My text!/h2
pHere is my text and the variable is: {{ settings.test_text }}/p
{% endblocktrans %}
{% endblock %}


I get the first part of the text, but the variable is not there at all.
thanks,

Brandon Keith Biggs http://www.brandonkeithbiggs.com/
On 7/16/2015 12:12 AM, Danny wrote:

On 16/07/2015 7:30 AM, Brandon Keith Biggs wrote:

Hello,
Is there an easy way to create template variables and functions 
without modifying the site urls?

Perhaps in mezzanine_tags or something?
A variable like
{{ mezzanine.my_app.my_variable }}
would be fine.
Is this what page can help with? I want to use these variables in my 
custom theme.

thank you,


I think what you might be looking for is to create your own setting, 
and then use it in a template, right?


http://mezzanine.readthedocs.org/en/latest/configuration.html

Basically:
In your app, create a defaults.py, and use register_setting() to 
create the variable you want.
It can be editable in the admin if you like, or just configurable via 
settings/local_settings.py


Then you'll need to update TEMPLATE_ACCESSIBLE_SETTINGS so that your 
new setting is listed there,

making it accessible within templates.

And then you should be able to just reference {{settings.variable}} in 
any template that has mezzanine_tags loaded.


For example, I have in my app's defaults.py:

register_setting(
name=SOCIAL_FACEBOOK,
description=Link to Facebook Page. Include http prefix.,
editable=True,
default=,
)
register_setting(
name=TEMPLATE_ACCESSIBLE_SETTINGS,
append=True,
default=(SOCIAL_FACEBOOK,),
)

And then in my base.html:

{% load mezzanine_tags ... %}
...
{% if settings.SOCIAL_FACEBOOK %}
a href={{ settings.SOCIAL_FACEBOOK }}Facebook/a
{% endif %}

So this allows me to add a link to my Facebook page in the admin 
(Settings section) and have that link show up on every page of the 
site via the base.html template.


Seeya. Danny.


--
*Danny Sag*
Chairperson
Round World Events SA, Inc
City of Small Gods Terry Pratchett Fan Club - 
http://cityofsmallgods.org.au


*Nullus Anxietas VI - The Australian Discworld Convention* - 
http://ausdwcon.org

The Discworld Grand Tour - Adelaide SA, August 4-6, 2017
--
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 
mailto:mezzanine-users+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Brandon Keith Biggs

Hello,
That was totally the problem!

I would like to be able to keep the translation ability for the 
variables, is there any way to use a filter on the text before it goes 
into blocktrans?

I tried doing something like:

my_app/templatetags/module.py
from django import template
register = template.Library()

my_theme/templates/index.html
{% load shortcodes %}
...
{% block main|test_filter %}
{% blocktrans %}
h2My text!/h2
pI like flowers, apples, flowers, oranges, flowers and flowers!/p
{% endblocktrans %}
{% endblock %}

and nothing shows up on the page...
I've already got a filter I am using for richtext, so I'll just transfer 
that over if I can.


Other question, if I'm not to use html tags in the translated area, what 
do I use? Do I just put a whole lot of blocktrans tags in my html tags?

Thanks,

Brandon Keith Biggs http://www.brandonkeithbiggs.com/
On 7/16/2015 1:18 AM, Eduardo Rivas wrote:
That should work without issue, though I generally like to bundle all 
the as tags on top of the block.


{% block main %}
{% get_sitewide_content as sitewide %}
h1my text/h1
{{ sitewide.foobar }}
{% endblock %}

Also, be careful with the blocktrans tag, you need to explicitly bind 
any variable you want to use inside them. You should also avoid 
including HTML tags inside them to prevent poluting the gettext 
catalog with markup 
https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#blocktrans-template-tag.




--
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] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Brandon Keith Biggs

Hello,
Is there an easy way to create template variables and functions without 
modifying the site urls?

Perhaps in mezzanine_tags or something?
A variable like
{{ mezzanine.my_app.my_variable }}
would be fine.
Is this what page can help with? I want to use these variables in my 
custom theme.

thank you,

--
Brandon Keith Biggs http://www.brandonkeithbiggs.com/

--
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Danny

On 16/07/2015 7:30 AM, Brandon Keith Biggs wrote:

Hello,
Is there an easy way to create template variables and functions 
without modifying the site urls?

Perhaps in mezzanine_tags or something?
A variable like
{{ mezzanine.my_app.my_variable }}
would be fine.
Is this what page can help with? I want to use these variables in my 
custom theme.

thank you,


I think what you might be looking for is to create your own setting, and 
then use it in a template, right?


http://mezzanine.readthedocs.org/en/latest/configuration.html

Basically:
In your app, create a defaults.py, and use register_setting() to create 
the variable you want.
It can be editable in the admin if you like, or just configurable via 
settings/local_settings.py


Then you'll need to update TEMPLATE_ACCESSIBLE_SETTINGS so that your new 
setting is listed there,

making it accessible within templates.

And then you should be able to just reference {{settings.variable}} in 
any template that has mezzanine_tags loaded.


For example, I have in my app's defaults.py:

register_setting(
name=SOCIAL_FACEBOOK,
description=Link to Facebook Page. Include http prefix.,
editable=True,
default=,
)
register_setting(
name=TEMPLATE_ACCESSIBLE_SETTINGS,
append=True,
default=(SOCIAL_FACEBOOK,),
)

And then in my base.html:

{% load mezzanine_tags ... %}
...
{% if settings.SOCIAL_FACEBOOK %}
a href={{ settings.SOCIAL_FACEBOOK }}Facebook/a
{% endif %}

So this allows me to add a link to my Facebook page in the admin 
(Settings section) and have that link show up on every page of the site 
via the base.html template.


Seeya. Danny.


--
*Danny Sag*
Chairperson
Round World Events SA, Inc
City of Small Gods Terry Pratchett Fan Club - http://cityofsmallgods.org.au

*Nullus Anxietas VI - The Australian Discworld Convention* - 
http://ausdwcon.org

The Discworld Grand Tour - Adelaide SA, August 4-6, 2017

--
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.


Re: [mezzanine-users] Easy way to grab data from an installed app in the templates

2015-07-15 Thread Eduardo Rivas
As an alternative, you can also use SingletonAdmin and a template tag to 
make model data available anywhere in the site. Josh wrote about it and 
I follow this pattern all the time: 
http://bitofpixels.com/blog/on-singletonadmins-and-sitewidecontent-editing-sitewide-content-in-mezzanines-admin/.


--
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.


Re: [mezzanine-users] Re: Migrations for EXTRA_MODEL_FIELDS in Mezzanine 4

2015-07-15 Thread Josh Cartmell
Thanks Ed, I gave that a shot but it resulted in other errors, probably
because then the rest of forms migrations were missing.

It would also make migrating in production a very onerous process and I
think greatly reduces the utility of EXTRA_MODEL_FIELDS since they would no
longer work with Fabric.

I came up with the following to address the problem
https://gist.github.com/joshcartme/f8dc0f3a238024c52681

The problem was that the app_label being used by the migrations, i.e.
https://github.com/django/django/blob/master/django/db/migrations/operations/fields.py#L43,
was incorrect.  So that app_label was form_mods when really I would want it
to be forms.

The above works, but is only a partial solution since it supports adding
fields but not other potential migration operations.

I think the best solution may be getting a patch in Django itself that
allows specifying the app_label (like I did in my gist) to any migration
operation.  Then maybe we could add a little sugar in mezzanine around the
makemigrations command that adds the app_label if the field being modified
is in EXTRA_MODEL_FIELDS.

Thoughts?

On Tue, Jul 14, 2015 at 1:48 PM, Eduardo Rivas jerivasmel...@gmail.com
wrote:

 Perhaps something like this:
 https://docs.djangoproject.com/en/1.8/ref/settings/#migration-modules?

 Not sure how that's gonna work when Mezzanine itself ships some new
 migrations in the future. Maybe one has to toggle MIGRATION_MODULES
 manually to apply the correct migrations.

 --
 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.


-- 
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] Mezzanine 4.0.0 : staff users

2015-07-15 Thread Déborah Leder


https://lh3.googleusercontent.com/-TfOnEYdyMIs/VaaA1zdIEEI/AL4/xrvPacV4XOw/s1600/Capture_mezzanine.PNG
Hello

I have recently updated to mezzanine 4 and I have encountered an issue.
When I create a user who is active and is a staff member, the user can't 
log in to the admin interface. I have an error message (cf. image)
When I create another superuser, the other superuser can log in the admin 
site.

I had started to work on mezzanine 3.1.10 two weeks ago and I managed to 
create a Staff member user who could log in the admin site.
Has something changed in the permission ? Or is it a bug ? And if so, when 
do you think it could/would be solved ? (I am actually working and using 
mezzanine for a client for whom I must have finished the site in a month, 
so if it is going to take more than a week to fix, which I could completely 
understand, I need to know to go back to the older version)

Deborah.

-- 
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.