Skip to content

Commit

Permalink
Add user blocking feature - EDLY-3498 (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
taimoor-ahmed-1 authored Aug 25, 2021
1 parent 0af8706 commit 1c6eac2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# pylint: skip-file
# Generated by Django 2.2.16 on 2021-08-23 13:05

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('edly', '0007_make_edx_organizations_m2m'),
]

operations = [
migrations.AddField(
model_name='edlyuserprofile',
name='is_blocked',
field=models.BooleanField(
default=False,
help_text='Block/Unblock user from logging in to the platform.',
verbose_name='Blocked'
),
),
]
6 changes: 6 additions & 0 deletions openedx/features/edly/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.sites.models import Site
from django.core.validators import RegexValidator
from django.db import models
from django.utils.translation import ugettext_lazy as _

from model_utils.models import TimeStampedModel
from organizations.models import Organization
Expand Down Expand Up @@ -60,6 +61,11 @@ class EdlyUserProfile(models.Model):
user = models.OneToOneField(User, unique=True, db_index=True, related_name='edly_profile', on_delete=models.CASCADE)
edly_sub_organizations = models.ManyToManyField(EdlySubOrganization)
course_activity_date = models.DateTimeField(blank=True, null=True)
is_blocked = models.BooleanField(
default=False,
verbose_name='Blocked',
help_text=_('Block/Unblock user from logging in to the platform.')
)

@property
def get_linked_edly_sub_organizations(self):
Expand Down
11 changes: 11 additions & 0 deletions openedx/features/edly/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,14 @@ def test_edly_user_profile_on_user_creation(self):
edly_user_profile = EdlyUserProfile.objects.filter(user=edly_user)
assert edly_user_profile.count() == 1
assert edly_user_profile[0].user == edly_user

def test_edly_user_profile_is_blocked_attr(self):
"""
Test "EdlyUserProfile" attr "is_blocked" bool.
"""

edly_user_profile = EdlyUserProfileFactory()
assert not edly_user_profile.is_blocked

edly_user_profile.is_blocked = True
assert edly_user_profile.is_blocked

0 comments on commit 1c6eac2

Please sign in to comment.