Commit f2c3c7dc authored by Skia's avatar Skia

Add viewable flag for user

parent eef5dfd2
Pipeline #136 failed with stage
in 2 minutes and 14 seconds
# -*- 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,
......
This diff is collapsed.
......@@ -132,6 +132,7 @@ def migrate_users():
parent_address=(to_unicode(u['adresse_parents']) + ", " + to_unicode(u['cpostal_parents']) + " " + to_unicode(u['ville_parents'])),
phone=u['tel_portable_utl'] or "",
parent_phone=u['tel_parents'] or "",
is_subscriber_viewable=bool(u['publique_utl']),
)
new.generate_username()
new.save()
......@@ -602,24 +603,23 @@ def migrate_permanencies():
cur.close()
def main():
# migrate_users()
# migrate_profile_pict()
# migrate_clubs()
# migrate_club_memberships()
# migrate_subscriptions()
# update_customer_account()
# migrate_counters()
# migrate_permanencies()
# migrate_typeproducts()
# migrate_products()
# migrate_product_pict()
# migrate_products_to_counter()
migrate_users()
migrate_profile_pict()
migrate_clubs()
migrate_club_memberships()
migrate_subscriptions()
update_customer_account()
migrate_counters()
migrate_permanencies()
migrate_typeproducts()
migrate_products()
migrate_product_pict()
migrate_products_to_counter()
# reset_customer_amount()
# migrate_invoices()
# migrate_refillings()
# migrate_sellings()
reset_index('core')
# reset_index('core', 'club', 'subscription', 'accounting', 'eboutic', 'launderette', 'counter')
migrate_invoices()
migrate_refillings()
migrate_sellings()
reset_index('core', 'club', 'subscription', 'accounting', 'eboutic', 'launderette', 'counter')
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment