|
4 | 4 | import sys |
5 | 5 | import os |
6 | 6 | import json |
| 7 | +import datetime |
7 | 8 |
|
8 | 9 | appdir = os.path.abspath(os.path.dirname(__file__)) |
9 | 10 | projdir = os.path.abspath(os.path.join(appdir, '..')) |
@@ -250,7 +251,7 @@ def mutate(self, info, input): |
250 | 251 | local_db_session.commit() |
251 | 252 | stage = DBSession.query(StageModel).filter( |
252 | 253 | StageModel.id == data['id']).first() |
253 | | - |
| 254 | + |
254 | 255 | return UpdateStage(stage=stage) |
255 | 256 |
|
256 | 257 |
|
@@ -308,6 +309,29 @@ def mutate(self, info, stage_id): |
308 | 309 | local_db_session.commit() |
309 | 310 | return UpdateAttributeVisibility(result=attribute.description) |
310 | 311 |
|
| 312 | + |
| 313 | +class UpdateLastAccess(graphene.Mutation): |
| 314 | + """Mutation to update a stage last access attribute.""" |
| 315 | + result = graphene.String() |
| 316 | + |
| 317 | + class Arguments: |
| 318 | + stage_id = graphene.ID( |
| 319 | + required=True, description="Global Id of the stage.") |
| 320 | + |
| 321 | + |
| 322 | + # decorate this with jwt login decorator. |
| 323 | + def mutate(self, info, stage_id): |
| 324 | + with ScopedSession() as local_db_session: |
| 325 | + _id = int(stage_id) |
| 326 | + stage = local_db_session.query(StageModel).filter(StageModel.id == _id); |
| 327 | + if stage: |
| 328 | + stage.update({ |
| 329 | + StageModel.last_access: datetime.datetime.utcnow() |
| 330 | + }, synchronize_session="fetch") |
| 331 | + |
| 332 | + local_db_session.commit() |
| 333 | + return UpdateLastAccess(result= datetime.datetime.utcnow()) |
| 334 | + |
311 | 335 | class AssignMediaInput(graphene.InputObjectType): |
312 | 336 | id = graphene.ID(required=True, description="Global Id of the stage.") |
313 | 337 | media_ids = graphene.List(graphene.Int, description="Id of assigned media") |
@@ -403,6 +427,9 @@ def mutate(self, info, id): |
403 | 427 | ParentStage.stage_id == id).delete(synchronize_session=False) |
404 | 428 | local_db_session.query(StageAttributeModel).filter( |
405 | 429 | StageAttributeModel.stage_id == id).delete(synchronize_session=False) |
| 430 | + local_db_session.query(SceneModel).filter( |
| 431 | + SceneModel.stage_id == id).delete(synchronize_session=False) |
| 432 | + |
406 | 433 | for performance in local_db_session.query(PerformanceModel).filter( |
407 | 434 | PerformanceModel.stage_id == id).all(): |
408 | 435 | local_db_session.query(EventModel).filter( |
@@ -444,6 +471,8 @@ def mutate(self, info, id, name): |
444 | 471 | stage.id = None |
445 | 472 | stage.name = name |
446 | 473 | stage.owner_id = user.id |
| 474 | + stage.last_access = None |
| 475 | + stage.created_on = datetime.datetime.utcnow() |
447 | 476 | shortname = re.sub( |
448 | 477 | '\s+', '-', re.sub('[^A-Za-z0-9 ]+', '', name)).lower() |
449 | 478 |
|
@@ -498,12 +527,13 @@ class Mutation(graphene.ObjectType): |
498 | 527 | saveRecording = SaveRecording.Field() |
499 | 528 | updateStatus = UpdateAttributeStatus.Field() |
500 | 529 | updateVisibility = UpdateAttributeVisibility.Field() |
| 530 | + updateLastAccess = UpdateLastAccess.Field() |
501 | 531 |
|
502 | 532 |
|
503 | 533 | class Query(graphene.ObjectType): |
504 | 534 | node = relay.Node.Field() |
505 | 535 | stageList = StageConnectionField( |
506 | | - Stage.connection, id=graphene.ID(), name_like=graphene.String(), file_location=graphene.String()) |
| 536 | + Stage.connection, id=graphene.ID(), name_like=graphene.String(), file_location=graphene.String(), created_on=graphene.DateTime()) |
507 | 537 | assetList = AssetConnectionField( |
508 | 538 | Asset.connection, id=graphene.ID(), name_like=graphene.String(), asset_type=graphene.String(), file_location=graphene.String()) |
509 | 539 | assetTypeList = StageConnectionField( |
|
0 commit comments