Ticket #46 (assigned defect)

Opened 3 months ago

Last modified 2 months ago

Split SubmitEntries & use templates

Reported by: ctrochalakis Owned by: Telimektar
Priority: major Milestone:
Component: Core Version:
Keywords: easy_task code_quality Cc:

Description

Split transifex.util.SubmitEntries? to 3 classes:

ex. ModuleSubmissionTable?, UserSubmissionsTable?, AllSubmissionsTable?

Also there should be a way to define an external template instead of using python code to generate html.

Change History

  Changed 2 months ago by Telimektar

  • owner changed from Dimitris Glezos to Telimektar
  • status changed from new to assigned

  Changed 2 months ago by glezos

Note: We'll want to call these, somehow, from our CLI client as well. So returning HTML shouldn't be the *default* behavior.

  Changed 2 months ago by ctrochalakis

Cli uses the api and the api methods return plain "unformatted" data from the server, so we 'll not be needing those.

follow-up: ↓ 5   Changed 2 months ago by glezos

The purpose of this class is mainly to handle the complex things the ActionLog? table needs. Returning HTML should be one of the outputs, as well as plain objects. So we should expect to call it from both the API and HTML controllers.

Here's a quick idea:

entries = SubmitEntries(user='jdoe').entries        # Calling from the API
entries_html = SubmitEntries(user='jdoe').in_html() # Calling from a controller

Telimektar, actually, the best place to put these methods would be inside the model itself. Implementing a get_entries() class method (@classmethod decorator, already used in model.py would make more sense, and will allow us to call them like this:

user_entries = ActionLog.entries.by_user(name='jdoe')
module_entries_html = ActionLog.entries.by_module(name='tx').as_html()

Does this make sense guys?

in reply to: ↑ 4   Changed 2 months ago by ctrochalakis

Replying to glezos:

Telimektar, actually, the best place to put these methods would be inside the model itself. Implementing a get_entries() class method (@classmethod decorator, already used in model.py would make more sense, and will allow us to call them like this:

{{{
user_entries = ActionLog?.entries.by_user(name='jdoe')
module_entries_html = ActionLog?.entries.by_module(name='tx').as_html()
}}}

Does this make sense guys?

User.submit_entries would make more sense, along with Module.submit_entries, etc.
Where submit_entries is a sqlalchemy relation between User/Module and ActionLog? sqla model classes.

>>> a_user.submit_entries
>>> a_module.submit_entries
>>> type(a_module.submit_entries)
<class 'sqlalchemy.orm.collections.InstrumentedList'>

What do you think of this?

Note: See TracTickets for help on using tickets.