Update readonly property on user
This commit is contained in:
parent
249abff36b
commit
71bd9f6d14
|
|
@ -31,7 +31,7 @@
|
|||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
@import "@/styles/_variables.scss";
|
||||
@import "~styles/helpers";
|
||||
|
||||
.assignment-form {
|
||||
display: grid;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from datetime import timedelta, datetime
|
||||
|
||||
from graphql_relay import to_global_id
|
||||
|
||||
from assignments.factories import AssignmentFactory, StudentSubmissionFactory
|
||||
|
|
@ -9,7 +11,12 @@ from users.models import User
|
|||
class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
||||
def setUp(self) -> None:
|
||||
self.createDefault()
|
||||
self.student = User.objects.get(username='student1')
|
||||
yesterday = datetime.now() - timedelta(days=1)
|
||||
|
||||
self.student1.license_expiry_date = yesterday
|
||||
self.student1.save()
|
||||
self.teacher.license_expiry_date = yesterday
|
||||
self.teacher.save()
|
||||
self.assignment = AssignmentFactory()
|
||||
self.assignment_id = to_global_id('AssignmentNode', self.assignment.id)
|
||||
|
||||
|
|
@ -24,7 +31,7 @@ class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
|||
}
|
||||
}
|
||||
}
|
||||
result = self.get_client(self.student).execute(UPDATE_ASSIGNMENT_MUTATION, variables=variables)
|
||||
result = self.get_client(self.student1).execute(UPDATE_ASSIGNMENT_MUTATION, variables=variables)
|
||||
self.assertIsNotNone(result.get('errors'))
|
||||
|
||||
def test_share_assignment_fails(self):
|
||||
|
|
@ -38,7 +45,7 @@ class AssignmentReadOnlyTestCase(SkillboxTestCase):
|
|||
}
|
||||
}
|
||||
}
|
||||
result = self.get_client(self.student).execute(UPDATE_ASSIGNMENT_MUTATION, variables=variables)
|
||||
result = self.get_client(self.student1).execute(UPDATE_ASSIGNMENT_MUTATION, variables=variables)
|
||||
self.assertIsNotNone(result.get('errors'))
|
||||
|
||||
def test_edit_feedback_fails(self):
|
||||
|
|
|
|||
|
|
@ -119,18 +119,16 @@ class User(AbstractUser):
|
|||
def full_name(self):
|
||||
return self.get_full_name()
|
||||
|
||||
@cached_property
|
||||
@property
|
||||
def read_only(self):
|
||||
# todo: just mocked for now, link to license before release
|
||||
return True
|
||||
return self.get_license_status() == User.LICENSE_EXPIRED
|
||||
|
||||
def get_license_status(self):
|
||||
if not self.license_expiry_date:
|
||||
if self.license_expiry_date is None:
|
||||
return User.LICENSE_NONE
|
||||
now = datetime.now()
|
||||
if self.license_expiry_date >= now:
|
||||
if self.license_expiry_date >= datetime.now():
|
||||
return User.LICENSE_VALID
|
||||
return User.LICENSE_NONE
|
||||
return User.LICENSE_EXPIRED
|
||||
|
||||
class Meta:
|
||||
ordering = ['pk', ]
|
||||
|
|
|
|||
Loading…
Reference in New Issue