Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yelizariev committed May 6, 2024
1 parent 23727be commit 8690717
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 29 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated from manifests external_dependencies
bravado_core
jsonschema<4
mistune
markdown
swagger_spec_validator
22 changes: 14 additions & 8 deletions sync/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Sync 🪬 Studio",
"summary": """Synchronize something with anything: SystemX↔Odoo, Odoo1↔Odoo2, SystemX↔SystemY. ETL/ESB tool similar to OCA/connector, but more flexible""",
"summary": """Join the Amazing 😍 Community ⤵️""",
"category": "Extra Tools",
"images": ["images/sync-studio.jpg"],
"version": "16.0.7.0.0",
Expand All @@ -15,7 +15,7 @@
"website": "https://sync_studio.t.me/",
"license": "Other OSI approved licence", # MIT
"depends": ["base_automation", "mail", "queue_job"],
"external_dependencies": {"python": ["mistune"], "bin": []},
"external_dependencies": {"python": ["markdown"], "bin": []},
"data": [
"security/sync_groups.xml",
"security/ir.model.access.csv",
Expand All @@ -32,13 +32,19 @@
"wizard/sync_make_module_views.xml",
"data/queue_job_function_data.xml",
],
"assets": {
"web.assets_backend": [
"sync/static/src/scss/src.scss",
],
},
"demo": [
"data/sync_project_context_demo.xml",
"data/sync_project_telegram_demo.xml",
"data/sync_project_odoo2odoo_demo.xml",
"data/sync_project_trello_github_demo.xml",
"data/sync_project_unittest_demo.xml",
"data/sync_project_context_demo.xml",
# Obsolete
# "data/sync_project_context_demo.xml",
# "data/sync_project_telegram_demo.xml",
# "data/sync_project_odoo2odoo_demo.xml",
# "data/sync_project_trello_github_demo.xml",
# "data/sync_project_unittest_demo.xml",
# "data/sync_project_context_demo.xml",
],
"qweb": [],
"post_load": None,
Expand Down
16 changes: 12 additions & 4 deletions sync/models/sync_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import base64
import logging
from datetime import datetime

from pytz import timezone

Expand All @@ -13,7 +14,7 @@
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT, frozendict, html2plaintext
from odoo.tools.misc import get_lang
from odoo.tools.safe_eval import (
datetime,
datetime as safe_datetime,
dateutil,
json,
safe_eval,
Expand Down Expand Up @@ -52,7 +53,8 @@ class SyncProject(models.Model):
"Source",
help="Paste link to gist page, e.g. https://gist.github.com/yelizariev/e0585a0817c4d87b65b8a3d945da7ca2",
)
description = fields.Html()
source_updated_at = fields.Datetime("Version", readonly=True)
description = fields.Html(readonly=True)

# Deprecated, please use eval_context_ids
# TODO: delete in v17 release
Expand Down Expand Up @@ -287,7 +289,7 @@ def record2image(record, fname=None):
"url2bin": url2bin,
"html2plaintext": html2plaintext,
"time": time,
"datetime": datetime,
"datetime": safe_datetime,
"dateutil": dateutil,
"timezone": timezone,
"b64encode": base64.b64encode,
Expand Down Expand Up @@ -442,6 +444,9 @@ def magic_upgrade(self):
gist_content = fetch_gist_data(self.source_url)

project_name = gist_content.get("description", "Sync 🪬 Studio")
source_updated_at = datetime.strptime(
gist_content.get("updated_at"), "%Y-%m-%dT%H:%M:%SZ"
)

# Extract files
gist_files = {}
Expand All @@ -459,11 +464,14 @@ def magic_upgrade(self):

self.update(
{
"name": project_name,
"description": readme,
"source_updated_at": source_updated_at,
}
)

if not self.name:
self.name = project_name


class SyncProjectParamMixin(models.AbstractModel):

Expand Down
6 changes: 6 additions & 0 deletions sync/static/src/scss/src.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.html_field_container {
padding: 0 2em;
}
.html_field_container img {
max-width: 100%;
}
4 changes: 2 additions & 2 deletions sync/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
import re

import mistune
import markdown
import requests
import urllib3

Expand Down Expand Up @@ -72,7 +72,7 @@ def url2base64(url):
def compile_markdown_to_html(markdown_content):
markdown_content = remove_front_matter(markdown_content)

html = mistune.markdown(markdown_content)
html = markdown.markdown(markdown_content)

return html

Expand Down
33 changes: 19 additions & 14 deletions sync/views/sync_project_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,27 @@
<notebook>
<page name="readme" string="Documentation">
<group>
<field
name="source_url"
widget="url"
placeholder="https://gist.github.com/yelizariev/e0585a0817c4d87b65b8a3d945da7ca2"
/>
<button
name="magic_upgrade"
string="Upgrade"
class="oe_highlight"
type="object"
confirm="ATTENTION! This action will override all task code (but will not affect parameter values if already set). Proceed?"
/>
<group>
<field
name="source_url"
widget="url"
placeholder="E.g. https://gist.github.com/yelizariev/e0585a0817c4d87b65b8a3d945da7ca2"
/>
<field name="source_updated_at" />
</group>
<group>
<button
name="magic_upgrade"
string="Upgrade"
class="oe_highlight"
type="object"
confirm="ATTENTION! This action will override all task code. PROCEED? (Parameter values will stay as is)"
/>
</group>
</group>
<group>
<div class="html_field_container">
<field name="description" nolabel="1" />
</group>
</div>
</page>
<page name="buttons" string="Manual Triggers">
<p class="oe_edit_only">
Expand Down

0 comments on commit 8690717

Please sign in to comment.