Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UPD] ssi_data_requirement_google_drive #5

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ssi_data_requirement_google_drive/models/data_requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ def _create_google_doc(self):
google_docs_template_id = self._get_google_docs_template_id()
new_google_doc_name = self._get_new_google_doc_name()
google_docs_folder_id = self._get_google_docs_folder_id()
google_docs_template_type = self._get_google_docs_template_type()
gdocs_url = (
"https://docs.google.com/spreadsheets/d/%s/copy?id=%s&title=%s&copyDestination=%s"
"https://docs.google.com/%s/d/%s/copy?id=%s&title=%s&copyDestination=%s"
% (
google_docs_template_type,
google_docs_template_id,
google_docs_template_id,
new_google_doc_name,
Expand All @@ -55,6 +57,22 @@ def _get_new_google_doc_name(self):

return result

def _get_google_docs_template_type(self):
self.ensure_one()

if not self.type_id.google_docs_type:
error_message = """
Context: Create new google doc from data requirement
Database ID: %s
Problem: No google docs template type
Solution: Insert google docs template type on data requirement type
""" % (
self.id,
)
raise UserError(_(error_message))

return self.type_id.google_docs_type

def _get_google_docs_template_id(self):
self.ensure_one()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ class DataRequirementType(models.Model):
google_docs_template_id = fields.Char(
string="Google Docs Template ID",
)
google_docs_type = fields.Selection(
string="Google Docs Type",
selection=[
("spreadsheets", "Google Sheet"),
("forms", "Google Form"),
],
required=False,
default="spreadsheets",
)
google_docs_new_name = fields.Char(
string="Google Docs New Name",
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<data>
<xpath expr="//field[@name='mode']" position="after">
<field name="google_docs_template_id" />
<field name="google_docs_type" />
<field name="google_docs_new_name" />
</xpath>
</data>
Expand Down
Loading