On Monday, July 10, 2017 at 11:48:18 PM UTC+3, Eduardo Rivas wrote:
>
> Hello Patrick.
>
>  
>
>    1. I don’t think there’s a setting to require a login for blog posts. 
>    I suggest you override Mezzanine’s blog patterns in your root urlconf and 
>    apply  the login_required decorator to the blog views. See: 
>    https://stackoverflow.com/a/5771286/1330003
>    2. If you want to apply custom logic to the signup process you can go 
>    with signals. Specifically the post_save signal on the User model. 
>    https://docs.djangoproject.com/en/1.11/topics/signals/
>
>
For future reference I have this in my models.py file : 

+++++++++++
from django.db.models.signals import post_save
from django.contrib.auth.models import User, Group
from mezzanine.core.models import SitePermission

def add_user_to_public_group(sender, instance, created, **kwargs):
    """Post-create user signal that adds the user to member group."""

    try:
        if created:
            instance.groups.add(Group.objects.get(name='member'))
            sender.objects.filter(id=instance.id).update(is_staff='1')
            siteperms = 
SitePermission.objects.create(user=sender.objects.get(id=instance.id))
            siteperms.sites.add(2)
    except Group.DoesNotExist:
        pass

post_save.connect(add_user_to_public_group, sender=User)
+++++++++++


I have created a group "member" with permissions to create/edit/delete blog 
posts.  Is that necessary or does the "staff" value override those 
permissions?


--
Patrick Shirkey
Boost Hardware Ltd

 

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to