Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
6e5add47
Commit
6e5add47
authored
6 years ago
by
sandroroux
Browse files
Options
Downloads
Patches
Plain Diff
Adds retire_user mixin.
parent
e0078abe
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openedx/core/djangolib/model_mixins.py
+22
-0
22 additions, 0 deletions
openedx/core/djangolib/model_mixins.py
with
22 additions
and
0 deletions
openedx/core/djangolib/model_mixins.py
+
22
−
0
View file @
6e5add47
...
...
@@ -12,3 +12,25 @@ class DeprecatedModelMixin(object):
Override to kill usage of this model.
"""
raise
TypeError
(
"
This model has been deprecated and should not be used.
"
)
class
DeletableByUserValue
(
object
):
"""
This mixin allows inheriting models to delete instances of the model
associated with some user.
"""
@classmethod
def
delete_by_user_value
(
cls
,
value
,
field
):
"""
Deletes instances of this model where ``field`` equals ``value``.
e.g.
``delete_by_user_value(value=
'
learner@example.com
'
, field=
'
email
'
)``
Returns True if any instances were deleted.
Returns False otherwise.
"""
filter_kwargs
=
{
field
:
value
}
num_deleted_records
,
_
=
cls
.
objects
.
filter
(
**
filter_kwargs
).
delete
()
return
num_deleted_records
>
0
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment