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

Suggested fixes to pr 290 #299

Merged
merged 7 commits into from Jan 4, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions flexmeasures/api/common/schemas/users.py
Expand Up @@ -10,10 +10,10 @@ class AccountIdField(fields.Integer):
Field that represents an account ID. It de-serializes from the account id to an account instance.
"""

def _deserialize(self, account_id: int, attr, obj, **kwargs) -> Account:
def _deserialize(self, account_id: str, attr, obj, **kwargs) -> Account:
account: Account = Account.query.filter_by(id=int(account_id)).one_or_none()
if account is None:
raise abort(404, f"Account {id} not found")
raise abort(404, f"Account {account_id} not found")
return account

def _serialize(self, account: Account, attr, data, **kwargs) -> int:
Expand Down
4 changes: 2 additions & 2 deletions flexmeasures/ui/crud/assets.py
Expand Up @@ -112,7 +112,7 @@ def process_internal_api_response(
"""

def expunge_asset():
# us if no insert wanted from a previous query which flushes its results
# use if no insert is wanted from a previous query which flushes its results
if asset in db.session:
db.session.expunge(asset)

Expand All @@ -136,7 +136,7 @@ def expunge_asset():

class AssetCrudUI(FlaskView):
"""
These views help us offering a Jinja2-based UI.
These views help us offer a Jinja2-based UI.
The main focus on logic is the API, so these views simply call the API functions,
and deal with the response.
Some new functionality, like fetching accounts and asset types, is added here.
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/ui/templates/crud/asset.html
Expand Up @@ -138,7 +138,7 @@ <h3>Location</h3>
<div class="col-sm-3"></div>
<div class="col-sm-6">

<h3>All sensors in this asset</h3>
<h3>All sensors for this asset</h3>
<table class="table table-striped table-responsive paginate">
<thead>
<tr>
Expand Down
10 changes: 4 additions & 6 deletions flexmeasures/ui/templates/crud/assets.html
Expand Up @@ -18,8 +18,7 @@ <h2>All assets owned by account {{account.name}}</h2>
<th class="text-right no-sort">Location</th>
<th class="text-right">Asset id</th>
<th class="text-right">Account id</th>
<th class="text-right no-sort">Entity address</th>
<th class="text-right no-sort">Old entity address (API v1)</th>
<th class="text-right no-sort">Sensors</th>
<th class="text-right no-sort">
{% if user_is_admin %}
<form action="/assets/new" method="get">
Expand All @@ -38,8 +37,10 @@ <h2>All assets owned by account {{account.name}}</h2>
href="/assets/{{ asset.id }}" alt="Edit this asset">{{ asset.name }}</a></i>
</td>
<td class="text-right">
{% if asset.latitude and asset.longitude %}
LAT: {{ "{:,.4f}".format( asset.latitude ) }} LONG:
{{ "{:,.4f}".format( asset.longitude ) }}
{% endif %}
</td>
<td class="text-right">
{{ asset.id }}
Expand All @@ -48,10 +49,7 @@ <h2>All assets owned by account {{account.name}}</h2>
{{ asset.account_id }}
</td>
<td class="text-right">
{{ asset.entity_address }}
</td>
<td class="text-right">
{{ asset.entity_address_fm0 }}
{{ asset.sensors | length }}
</td>
<td class="text-right">
<form action="../../analytics" method="get">
Expand Down