File tree Expand file tree Collapse file tree 2 files changed +36
-9
lines changed
Expand file tree Collapse file tree 2 files changed +36
-9
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Data attributes for events within the architecture subdomain `learning`.
3+
4+ These attributes follow the form of attr objects specified in OEP-49 data
5+ pattern.
6+ """
7+ from datetime import datetime
8+ from uuid import UUID
9+
10+ import attr
11+
12+
13+ @attr .s (frozen = True )
14+ class EventsMetadata :
15+ """
16+ Attributes defined for events metadata object.
17+ """
18+
19+ id = attr .ib (type = UUID )
20+ event_type = attr .ib (type = str )
21+ minorversion = attr .ib (type = int )
22+ time = attr .ib (type = datetime )
23+ source = attr .ib (type = str )
24+ sourcehost = attr .ib (type = str )
25+ specversion = attr .ib (type = str )
26+ sourcelib = attr .ib (type = str )
Original file line number Diff line number Diff line change 1010from django .dispatch import Signal
1111
1212import openedx_events
13+ from openedx_events .data import EventsMetadata
1314from openedx_events .exceptions import InstantiationError , SenderValidationError
1415
1516
@@ -97,15 +98,15 @@ def get_source_lib():
9798 """
9899 return tuple (map (int , openedx_events .__version__ .split ("." )))
99100
100- return {
101- "id" : generate_uuid (),
102- " event_type" : self .event_type ,
103- " minorversion" : self .minor_version ,
104- " time" : get_current_time (),
105- " source" : get_source (),
106- " sourcehost" : get_source_host (),
107- " sourcelib" : get_source_lib (),
108- }
101+ return EventsMetadata (
102+ id = generate_uuid (),
103+ event_type = self .event_type ,
104+ minorversion = self .minor_version ,
105+ time = get_current_time (),
106+ source = get_source (),
107+ sourcehost = get_source_host (),
108+ sourcelib = get_source_lib (),
109+ )
109110
110111 def send_event (self , send_robust = False , ** kwargs ):
111112 """
You can’t perform that action at this time.
0 commit comments