Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Kort
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
AlekSIS®
Onboarding
AlekSIS-App-Kort
Commits
3a9e8fb9
Verified
Commit
3a9e8fb9
authored
1 year ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix models to work correctly with client secrets
parent
f00e832d
No related branches found
No related tags found
1 merge request
!14
Draft: Resolve "Object / Person identification using SDM NFC cards"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/kort/models/cards.py
+20
-5
20 additions, 5 deletions
aleksis/apps/kort/models/cards.py
with
20 additions
and
5 deletions
aleksis/apps/kort/models/cards.py
+
20
−
5
View file @
3a9e8fb9
...
@@ -14,6 +14,7 @@ from django.utils.translation import gettext as _
...
@@ -14,6 +14,7 @@ from django.utils.translation import gettext as _
from
celery.result
import
AsyncResult
from
celery.result
import
AsyncResult
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
oauth2_provider.generators
import
generate_client_secret
from
aleksis.core.mixins
import
ExtensibleModel
from
aleksis.core.mixins
import
ExtensibleModel
from
aleksis.core.models
import
OAuthApplication
,
Person
from
aleksis.core.models
import
OAuthApplication
,
Person
...
@@ -82,27 +83,41 @@ class CardPrinter(ExtensibleModel):
...
@@ -82,27 +83,41 @@ class CardPrinter(ExtensibleModel):
null
=
True
,
null
=
True
,
related_name
=
"
card_printers
"
,
related_name
=
"
card_printers
"
,
)
)
oauth2_client_secret
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
verbose_name
=
_
(
"
OAuth2 client secret
"
),
)
# Settings
# Settings
cups_printer
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
"
CUPS printer
"
),
blank
=
True
)
cups_printer
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
"
CUPS printer
"
),
blank
=
True
,
help_text
=
_
(
"
Leave blank to deactivate CUPS printing
"
),
)
generate_number_on_server
=
models
.
BooleanField
(
generate_number_on_server
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
"
Generate card number on server
"
)
default
=
True
,
verbose_name
=
_
(
"
Generate card number on server
"
)
)
)
card_detector
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
"
Card detector
"
),
blank
=
True
)
card_detector
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
"
Card detector
"
),
blank
=
True
)
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
super
().
save
(
*
args
,
**
kwargs
)
if
not
self
.
oauth2_application
:
if
not
self
.
oauth2_application
:
client_secret
=
generate_client_secret
()
application
=
OAuthApplication
(
application
=
OAuthApplication
(
client_type
=
OAuthApplication
.
CLIENT_CONFIDENTIAL
,
client_type
=
OAuthApplication
.
CLIENT_CONFIDENTIAL
,
authorization_grant_type
=
OAuthApplication
.
GRANT_CLIENT_CREDENTIALS
,
authorization_grant_type
=
OAuthApplication
.
GRANT_CLIENT_CREDENTIALS
,
name
=
f
"
Card printer:
{
self
.
name
}
"
,
name
=
f
"
Card printer:
{
self
.
name
}
"
,
redirect_uris
=
"
urn:ietf:wg:oauth:2.0:oob
"
,
allowed_scopes
=
[
self
.
scope
],
allowed_scopes
=
[
self
.
scope
],
client_secret
=
client_secret
,
)
)
application
.
save
()
application
.
save
()
self
.
oauth2_application
=
application
self
.
oauth2_application
=
application
self
.
oauth2_client_secret
=
client_secret
super
().
save
(
*
args
,
**
kwargs
)
super
().
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
...
@@ -127,7 +142,7 @@ class CardPrinter(ExtensibleModel):
...
@@ -127,7 +142,7 @@ class CardPrinter(ExtensibleModel):
config
=
{
config
=
{
"
base_url
"
:
settings
.
BASE_URL
,
"
base_url
"
:
settings
.
BASE_URL
,
"
client_id
"
:
self
.
oauth2_application
.
client_id
,
"
client_id
"
:
self
.
oauth2_application
.
client_id
,
"
client_secret
"
:
self
.
oauth2_
application
.
client_secret
,
"
client_secret
"
:
self
.
oauth2_client_secret
,
}
}
return
config
return
config
...
@@ -294,7 +309,7 @@ class Card(ExtensibleModel):
...
@@ -294,7 +309,7 @@ class Card(ExtensibleModel):
}
}
def
generate_pdf
(
self
)
->
Union
[
bool
,
AsyncResult
]:
def
generate_pdf
(
self
)
->
Union
[
bool
,
AsyncResult
]:
from
.tasks
import
generate_card_pdf
from
.
.tasks
import
generate_card_pdf
if
self
.
pdf_file
:
if
self
.
pdf_file
:
return
True
return
True
...
...
This diff is collapsed.
Click to expand it.
Jonathan Weth
@hansegucker
mentioned in commit
6d28b4ff
·
1 year ago
mentioned in commit
6d28b4ff
mentioned in commit 6d28b4ff1aacc8c3ffe30a000e6a52f57f3b6feb
Toggle commit list
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