Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend_common_py
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package registry
Container registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
videoag
backend_common_py
Commits
1f6da757
Commit
1f6da757
authored
5 months ago
by
Simon Künzel
Browse files
Options
Downloads
Patches
Plain Diff
Fix missing check for time in announcements
parent
c805d09b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/videoag_common/database/base.py
+7
-0
7 additions, 0 deletions
src/videoag_common/database/base.py
src/videoag_common/objects/site.py
+11
-0
11 additions, 0 deletions
src/videoag_common/objects/site.py
with
18 additions
and
0 deletions
src/videoag_common/database/base.py
+
7
−
0
View file @
1f6da757
...
...
@@ -68,3 +68,10 @@ class Base(DeclarativeBase):
return
relationship
.
has
(
val
)
else
:
return
val
@hybrid_method
def
hybrid_is_none
(
self
,
expression
):
if
isinstance
(
self
,
type
):
return
expression
.
is_
(
None
)
else
:
return
expression
is
None
This diff is collapsed.
Click to expand it.
src/videoag_common/objects/site.py
+
11
−
0
View file @
1f6da757
...
...
@@ -61,6 +61,17 @@ class Announcement(DeletableApiObject, VisibilityApiObject, Base):
)
)
@hybrid_method
def
has_access
(
self
,
is_mod
:
bool
,
**
kwargs
):
cond
=
super
().
has_access
(
is_mod
,
**
kwargs
)
if
not
is_mod
:
current_time
=
datetime
.
now
()
cond
&=
self
.
hybrid_is_none
(
self
.
publish_time
)
|
(
self
.
publish_time
<=
current_time
)
cond
&=
self
.
hybrid_is_none
(
self
.
expiration_time
)
|
(
self
.
expiration_time
>
current_time
)
return
cond
class
FeaturedType
(
Enum
):
PLAIN
=
"
plain
"
...
...
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