Skip to content

Commit

Permalink
contact avatar support
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtepkeev committed Mar 24, 2024
1 parent 70772a8 commit 9110e04
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Changelog
- Support for ``issues_assigned`` and ``issues_authored`` relations in User object
(`Issue #317 <https://github.com/maxtepkeev/python-redmine/issues/317>`__)
- Original filename will be used as a filename for all uploaded files if a path was provided and filename wasn't set
- *Pro Edition:* Added support for RedmineUP Contact avatar add/update operations
(see `docs <https://python-redmine.com/resources/contact.html#create-methods>`__ for details)
- *Pro Edition:* Added support for RedmineUP DealCategory ``create()``, ``update()``, ``delete()`` operations
(see `docs <https://python-redmine.com/resources/deal_category.html#create-methods>`__ for details)
- *Pro Edition:* RedmineUP CrmQuery resource now supports ``invoices`` and ``expenses`` relation attributes
Expand Down
27 changes: 24 additions & 3 deletions docs/resources/contact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ create
- 1 - public
- 2 - private

:param dict avatar:
.. raw:: html

(optional). Avatar to be used for the contact as dict, accepted keys are:

- path (required). Absolute file path or file-like object that should be uploaded.
- filename (optional). Required if a file-like object is provided.

:return: :ref:`Resource` object

.. code-block:: python
Expand All @@ -82,7 +90,8 @@ create
... is_company=False,
... address_attributes={'street1': 'foo', 'street2': 'bar', 'city': 'Moscow', 'postcode': '111111', 'country_code': 'RU'},
... custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}],
... visibility=0
... visibility=0,
... avatar={'path': '/absolute/path/to/file.jpg'}
... )
>>> contact
<redminelib.resources.Contact #1 "Ivan Ivanov">
Expand Down Expand Up @@ -120,6 +129,7 @@ new
>>> contact.address_attributes = {'street1': 'foo', 'street2': 'bar', 'city': 'Moscow', 'postcode': '111111', 'country_code': 'RU'}
>>> contact.custom_fields = [{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}]
>>> contact.visibility = 0
>>> contact.avatar = {'path': '/absolute/path/to/file.jpg'}
>>> contact.save()
<redminelib.resources.Contact #1 "Ivan Ivanov">
Expand Down Expand Up @@ -311,6 +321,14 @@ update
- 1 - public
- 2 - private

:param dict avatar:
.. raw:: html

(optional). Avatar to be used for the contact as dict, accepted keys are:

- path (required). Absolute file path or file-like object that should be uploaded.
- filename (optional). Required if a file-like object is provided.

:return: True

.. code-block:: python
Expand All @@ -332,7 +350,8 @@ update
... is_company=False,
... address_attributes={'street1': 'foo', 'street2': 'bar', 'city': 'Moscow', 'postcode': '111111', 'country_code': 'RU'},
... custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}],
... visibility=0
... visibility=0,
... avatar={'path': '/absolute/path/to/file.jpg'}
... )
True
Expand Down Expand Up @@ -367,6 +386,7 @@ save
>>> contact.address_attributes = {'street1': 'foo', 'street2': 'bar', 'city': 'Moscow', 'postcode': '111111', 'country_code': 'RU'}
>>> contact.custom_fields = [{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}]
>>> contact.visibility = 0
>>> contact.avatar = {'path': '/absolute/path/to/file.jpg'}
>>> contact.save()
<redminelib.resources.Contact #12345 "Ivan Ivanov">
Expand All @@ -390,7 +410,8 @@ save
... is_company=False,
... address_attributes={'street1': 'foo', 'street2': 'bar', 'city': 'Moscow', 'postcode': '111111', 'country_code': 'RU'},
... custom_fields=[{'id': 1, 'value': 'foo'}, {'id': 2, 'value': 'bar'}],
... visibility = 0
... visibility=0,
... avatar={'path': '/absolute/path/to/file.jpg'}
... )
>>> contact
<redminelib.resources.Contact #12345 "Ivan Ivanov">
Expand Down

0 comments on commit 9110e04

Please sign in to comment.