Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
82543d88
Commit
82543d88
authored
3 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Use HashidMixin from flask_hashids
parent
37c244b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models.py
+11
-16
11 additions, 16 deletions
app/models.py
with
11 additions
and
16 deletions
app/models.py
+
11
−
16
View file @
82543d88
from
datetime
import
datetime
,
timedelta
from
flask
import
current_app
,
url_for
from
flask_hashids
import
HashidMixin
from
flask_login
import
UserMixin
from
itsdangerous
import
BadSignature
,
TimedJSONWebSignatureSerializer
from
time
import
sleep
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
import
xml.etree.ElementTree
as
ET
from
.
import
db
,
hashids
,
login
from
.
import
db
,
login
import
base64
import
enum
import
os
import
shutil
class
HashidMixin
:
@property
def
hashid
(
self
):
return
hashids
.
encode
(
self
.
id
)
class
Permission
(
enum
.
IntEnum
):
'''
Defines User permissions as integers by the power of 2. User permission
can be evaluated using the bitwise operator &.
'''
ADMINISTRATE
=
4
CONTRIBUTE
=
2
USE_API
=
1
class
FileMixin
:
...
...
@@ -33,16 +38,6 @@ class FileMixin:
}
class
Permission
(
enum
.
IntEnum
):
'''
Defines User permissions as integers by the power of 2. User permission
can be evaluated using the bitwise operator &.
'''
ADMINISTRATE
=
4
CONTRIBUTE
=
2
USE_API
=
1
class
Role
(
HashidMixin
,
db
.
Model
):
__tablename__
=
'
roles
'
# Primary key
...
...
@@ -578,7 +573,7 @@ class CorpusFile(FileMixin, HashidMixin, db.Model):
os
.
remove
(
self
.
path
)
except
OSError
:
current_app
.
logger
.
error
(
'
Removing {} led to an OSError!
'
.
format
(
self
.
path
)
f
'
Removing
{
self
.
path
}
led to an OSError!
'
)
pass
db
.
session
.
delete
(
self
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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