|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 | """Eiffel source change links.""" |
| 17 | + |
17 | 18 | import graphene |
18 | 19 |
|
19 | 20 | from eiffel_graphql_api.graphql.schemas.events import ( |
@@ -68,9 +69,45 @@ def resolve_source_change_created(self, _): |
68 | 69 | return SourceChangeCreated(event) |
69 | 70 |
|
70 | 71 |
|
71 | | -class SourceSubmittedPreviousVersion(Base): |
| 72 | +class SourceSubmittedPreviousVersion(graphene.ObjectType): |
72 | 73 | """Previous source submitted link.""" |
73 | 74 |
|
| 75 | + source_change_submitted = graphene.Field(SourceChangeSubmitted) |
| 76 | + |
| 77 | + def __init__(self, link): |
| 78 | + """Initialize link.""" |
| 79 | + # pylint:disable=super-init-not-called |
| 80 | + self.link = link |
| 81 | + |
| 82 | + def resolve_source_change_submitted(self, _): |
| 83 | + """Resolve source change submitted link.""" |
| 84 | + from ..union import NotFound # pylint:disable=import-outside-toplevel |
| 85 | + |
| 86 | + event = find_one( |
| 87 | + "EiffelSourceChangeSubmittedEvent", {"meta.id": self.link.get("target")} |
| 88 | + ) |
| 89 | + if event is None: |
| 90 | + return NotFound(self.link, "Could not find event in database.") |
| 91 | + return SourceChangeSubmitted(event) |
| 92 | + |
74 | 93 |
|
75 | | -class SourceCreatedPreviousVersion(SourceChange): |
| 94 | +class SourceCreatedPreviousVersion(graphene.ObjectType): |
76 | 95 | """Previous source created link.""" |
| 96 | + |
| 97 | + source_change_created = graphene.Field(SourceChangeCreated) |
| 98 | + |
| 99 | + def __init__(self, link): |
| 100 | + """Initialize link.""" |
| 101 | + # pylint:disable=super-init-not-called |
| 102 | + self.link = link |
| 103 | + |
| 104 | + def resolve_source_change_created(self, _): |
| 105 | + """Resolve source change created link.""" |
| 106 | + from ..union import NotFound # pylint:disable=import-outside-toplevel |
| 107 | + |
| 108 | + event = find_one( |
| 109 | + "EiffelSourceChangeCreatedEvent", {"meta.id": self.link.get("target")} |
| 110 | + ) |
| 111 | + if event is None: |
| 112 | + return NotFound(self.link, "Could not find event in database.") |
| 113 | + return SourceChangeCreated(event) |
0 commit comments