mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Add viewable flag for user
This commit is contained in:
19
core/migrations/0008_user_is_subscriber_viewable.py
Normal file
19
core/migrations/0008_user_is_subscriber_viewable.py
Normal file
@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0007_auto_20160813_0522'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='is_subscriber_viewable',
|
||||
field=models.BooleanField(default=True, verbose_name='is subscriber viewable'),
|
||||
),
|
||||
]
|
@ -167,6 +167,7 @@ class User(AbstractBaseUser):
|
||||
parent_phone = PhoneNumberField(_("parent phone"), null=True, blank=True)
|
||||
address = models.CharField(_("address"), max_length=128, blank=True, default="")
|
||||
parent_address = models.CharField(_("parent address"), max_length=128, blank=True, default="")
|
||||
is_subscriber_viewable = models.BooleanField(_("is subscriber viewable"), default=True)
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
@ -359,6 +360,9 @@ class User(AbstractBaseUser):
|
||||
def can_be_edited_by(self, user):
|
||||
return user.is_in_group(settings.SITH_MAIN_BOARD_GROUP) or user.is_root
|
||||
|
||||
def can_be_viewed_by(self, user):
|
||||
return (user.is_in_group(settings.SITH_MAIN_MEMBERS_GROUP) and self.is_subscriber_viewable) or user.is_root
|
||||
|
||||
def get_mini_item(self):
|
||||
return """
|
||||
<div class="mini_profile_link" >
|
||||
|
@ -98,7 +98,7 @@ class UserProfileForm(forms.ModelForm):
|
||||
fields = ['first_name', 'last_name', 'nick_name', 'email', 'date_of_birth', 'profile_pict', 'avatar_pict',
|
||||
'scrub_pict', 'sex', 'second_email', 'address', 'parent_address', 'phone', 'parent_phone',
|
||||
'tshirt_size', 'role', 'department', 'dpt_option', 'semester', 'quote', 'school', 'promo',
|
||||
'forum_signature']
|
||||
'forum_signature', 'is_subscriber_viewable']
|
||||
widgets = {
|
||||
'date_of_birth': SelectDate,
|
||||
'profile_pict': forms.ClearableFileInput,
|
||||
|
Reference in New Issue
Block a user