Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Medarbetarpuls
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Fares Espiro
Medarbetarpuls
Commits
48c6846f
Commit
48c6846f
authored
1 week ago
by
Johannes Graf
Browse files
Options
Downloads
Patches
Plain Diff
Getters added for survey-cards
parent
001b5cb9
No related branches found
No related tags found
1 merge request
!16
Feature/unanswered surveys
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Medarbetarpuls/medarbetarapp/models.py
+10
-0
10 additions, 0 deletions
Medarbetarpuls/medarbetarapp/models.py
Medarbetarpuls/medarbetarapp/views.py
+7
-1
7 additions, 1 deletion
Medarbetarpuls/medarbetarapp/views.py
with
17 additions
and
1 deletion
Medarbetarpuls/medarbetarapp/models.py
+
10
−
0
View file @
48c6846f
...
...
@@ -124,6 +124,14 @@ class CustomUser(AbstractBaseUser, PermissionsMixin): # pyright: ignore
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
name
}
(
{
self
.
email
}
)
"
# To see how many surveys this user has unanswered
def
count_unanswered_surveys
(
self
):
return
self
.
survey_results
.
filter
(
is_answered
=
False
).
count
()
# To get all unanswered surveys for this user
def
get_unanswered_surveys
(
self
):
return
self
.
survey_results
.
filter
(
is_answered
=
False
)
...
...
@@ -201,6 +209,8 @@ class SurveyResult(models.Model):
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
user
}
(
{
self
.
is_answered
}
)
"
class
BaseQuestionDetails
(
models
.
Model
):
...
...
This diff is collapsed.
Click to expand it.
Medarbetarpuls/medarbetarapp/views.py
+
7
−
1
View file @
48c6846f
...
...
@@ -279,4 +279,10 @@ def survey_status_view(request):
def
unanswered_surveys_view
(
request
):
return
render
(
request
,
"
unanswered_surveys.html
"
)
user
=
request
.
user
# Assuming the user is authenticated
unanswered_count
=
user
.
count_unanswered_surveys
()
unanswered_surveys
=
user
.
get_unanswered_surveys
()
return
render
(
request
,
"
unanswered_surveys.html
"
,
{
'
unanswered_count
'
:
unanswered_count
,
'
unanswered_surveys
'
:
unanswered_surveys
,
})
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