Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyOTRS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Som Connexió
OTRS
PyOTRS
Commits
cc2fdf3b
Commit
cc2fdf3b
authored
8 years ago
by
Robert Habermann
Browse files
Options
Downloads
Patches
Plain Diff
add attachment_get and dynamic_field_get to Article
parent
31514966
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyotrs/lib.py
+56
-0
56 additions, 0 deletions
pyotrs/lib.py
with
56 additions
and
0 deletions
pyotrs/lib.py
+
56
−
0
View file @
cc2fdf3b
...
...
@@ -171,6 +171,39 @@ class Article(object):
else
:
return
[]
def
attachment_get
(
self
,
a_filename
):
"""
attachment_get
Args:
a_filename (str): Filename of Attachment to retrieve
Returns:
**Attachment** or **None**
"""
result
=
[
x
for
x
in
self
.
attachments
if
x
.
Filename
==
"
{0}
"
.
format
(
a_filename
)]
if
result
:
return
result
[
0
]
else
:
return
None
def
dynamic_field_get
(
self
,
df_name
):
"""
dynamic_field_get
Args:
df_name (str): Name of DynamicField to retrieve
Returns:
**DynamicField** or **None**
"""
result
=
[
x
for
x
in
self
.
dynamic_fields
if
x
.
name
==
"
{0}
"
.
format
(
df_name
)]
if
result
:
return
result
[
0
]
else
:
return
None
def
field_get
(
self
,
f_name
):
return
self
.
fields
.
get
(
f_name
)
...
...
@@ -473,6 +506,29 @@ class Ticket(object):
Returns:
**dict**: Ticket represented as dict.
"""
# TODO 2016-11-06 (RH): to_dct representation of Ticket for OTRS
"""
dct = {}
try:
if self.attachments:
dct.update({
"
Attachment
"
: self.attachments})
except AttributeError:
pass
try:
if self.dynamic_fields:
dct.update({
"
DynamicField
"
: self.dynamic_fields})
except AttributeError:
pass
if self.fields:
dct.update(self.fields)
return {
"
Ticket
"
: dct}
"""
return
{
"
Ticket
"
:
self
.
__dict__
}
...
...
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