Skip to content

Commit 22a137c

Browse files
committed
Add ABC for views
1 parent 4ba6138 commit 22a137c

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

TODO.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
- For example, `views/new_allele.py` should be `views/allele.py`.
2020
- [x] We've found all views where this refactor is needed.
2121
- [x] We've made the changes.
22-
- [x] curations
23-
- [x] diseases
24-
- [x] home
25-
- [x] markers
26-
- [x] publications
27-
- [x] users
28-
29-
- [ ] Abstract base classes are in use.
30-
- [ ] Clients implement an abstract base class.
31-
- [ ] Selectors implement an abstract base class.
32-
- [ ] Services implement an abstract base class.
33-
- [ ] Views implement an abstract base class.
22+
23+
- [ ] Abstract base classes have been created.
24+
- [ ] We have an ABC for clients.
25+
- [ ] We have an ABC for selectors.
26+
- [ ] We have an ABC for services.
27+
- [x] We have an ABC for views.
28+
29+
- [ ] Abstract base views are in use.
30+
- [ ] Clients implement an ABC.
31+
- [ ] Selectors implement an ABC.
32+
- [ ] Services implement an ABC.
33+
- [ ] Views implement an ABC.
3434

3535
## The missing tests have been added.
3636

src/base/__init__.py

Whitespace-only changes.

src/base/views.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Provide base classes for views."""
2+
3+
from abc import ABC, abstractmethod
4+
5+
6+
class EntityView(ABC):
7+
"""Provide an abstract base class for entity views.
8+
9+
Here an entity refers to a model in the HCI that has a new page, an all page,
10+
and an overview page. Some examples include: curations, diseases, markers (alleles
11+
and haplotypes), and publications.
12+
"""
13+
14+
@abstractmethod
15+
def new(self) -> None:
16+
"""View the page that provides a form that creates a new entity."""
17+
18+
@abstractmethod
19+
def all(self) -> None:
20+
"""View the searchable table page for an entity."""
21+
22+
@abstractmethod
23+
def overview(self, human_readable_id: str) -> None:
24+
"""View the overview page for an entity.
25+
26+
Args:
27+
human_readable_id: The human-readable ID of the model for the entity.
28+
"""

0 commit comments

Comments
 (0)