Skip to content

Commit

Permalink
Merge pull request #109 from rl-institut/release/v0.1.5
Browse files Browse the repository at this point in the history
Release/v0.1.5
  • Loading branch information
henhuy committed Aug 13, 2020
2 parents b2f6a35 + 397e247 commit ac26370
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 12 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ Here is a template for new release sections
### Removed
-
```
## [0.1.5] 2020-08-13

### Added
- possibility to set custom urls as app urls on landing page

### Fixed
- error due to incompatible version of PyUtilib (oemof->pyomo->PyUtilib)

## [0.1.4] 2020-04-20

### Added
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ARG WAM_APPS
ENV WAM_APPS=$WAM_APPS
RUN echo "Installing reqiurements for following apps: $WAM_APPS"
RUN python /code/install_requirements.py
RUN pip install PyUtilib==5.6.3

# run entrypoint.sh
ENTRYPOINT ["/code/entrypoint.sh"]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
django==2.2.10
django==2.2.13
jmespath
gunicorn
pandas
Expand Down
7 changes: 1 addition & 6 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ <h3 class="hp-features__subheader">{{app.name}}</h3>
<img src="{% static app.icon %}" alt="{{app.name}}" class="hp_wam_img_small">
</div>
<div class="u-text--center u-margin--m">
{% if app.url_arg %}
{% url app.url path=app.url_arg as url %}
{% else %}
{% url app.url as url %}
{% endif %}
<a href="{{url}}" class="btn btn-cta" title="{{app.name}}">
<a href="{{app.url}}" class="btn btn-cta" title="{{app.name}}">
{{app.category.goto}}
<i class ="icon ion-chevron-right icon--small"></i>
</a>
Expand Down
58 changes: 53 additions & 5 deletions utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
from enum import Enum
from collections import namedtuple
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch


AppInfo = namedtuple(
"AppInfo", ["category", "name", "url", "closed", "icon", "url_arg"],
)
AppInfo.__new__.__defaults__ = (False, None, None)
class AppInfo:
"""App infos are used on WAM landing page"""

def __init__(
self,
category: str,
name: str,
url: str,
closed: bool = False,
icon: str = None,
url_arg: str = None,
):
"""
Parameters
----------
category:
Must be one of available app categories (AppCategory).
App is placed in corresponding category section.
name:
Is displayed on landing page
url: Either namespace url to django app, or fix url (to extern page)
closed:
If closed is active, a lock symbol is shown.
(Access restrictions have to be set up by the app itself)
icon: Icon to be shown on landing page
url_arg: Optional path argument to (namespace) url - relict? unused?
"""
self.category = category
self.name = name
self.__url = url
self.closed = closed
self.icon = icon
self.__url_arg = url_arg

@property
def url(self):
"""
Returns app url for landing page
First reverse namespace url is tried (with url args if given), if this fails,
url will be returned "as is".
"""
try:
if self.__url_arg is None:
url = reverse(self.__url)
else:
url = reverse(self.__url, kwargs={"path": self.__url_arg})
except NoReverseMatch:
url = self.__url
return url


class AppCategory(Enum):
Expand Down

0 comments on commit ac26370

Please sign in to comment.