mode serialize is in context of web, ie serialize the resulting list currently defaults to this context objects returns the database objects, ie for auto commit
( session, metadata_proposed, project, mode="serialize", user=None)
| 40 | |
| 41 | |
| 42 | def guide_view_core( session, |
| 43 | metadata_proposed, |
| 44 | project, |
| 45 | mode="serialize", |
| 46 | user=None): |
| 47 | """ |
| 48 | mode |
| 49 | serialize is in context of web, ie serialize the resulting list |
| 50 | currently defaults to this context |
| 51 | objects returns the database objects, ie for auto commit |
| 52 | |
| 53 | """ |
| 54 | |
| 55 | meta = default_metadata(metadata_proposed) |
| 56 | |
| 57 | start_time = time.time() |
| 58 | output_file_list = [] |
| 59 | limit_counter = 0 |
| 60 | |
| 61 | query = session.query(Guide) |
| 62 | |
| 63 | meta['guide_info'] = {} |
| 64 | |
| 65 | ### START FILTERS ### |
| 66 | if meta["my_stuff_only"]: |
| 67 | |
| 68 | # assumes in context of user doing search not API |
| 69 | user = User.get(session) |
| 70 | query = query.filter(Guide.member_created == user.member) |
| 71 | |
| 72 | #if meta["field"]: |
| 73 | # Get field id? or ... |
| 74 | # WIP |
| 75 | #query = query.filter(Job.field == None) |
| 76 | |
| 77 | |
| 78 | query = query.filter(Guide.project == project) |
| 79 | |
| 80 | |
| 81 | if meta['job_id'] and meta['mode'] == 'attach': |
| 82 | |
| 83 | job = Job.get_by_id(session = session, |
| 84 | job_id = meta['job_id']) |
| 85 | |
| 86 | ignore_id_list = [] |
| 87 | |
| 88 | # TODO eventually use templates |
| 89 | |
| 90 | if job.guide_default_id: |
| 91 | ignore_id_list.append(job.guide_default_id) |
| 92 | serialized = job.guide_default.serialize_for_list_view() |
| 93 | serialized["kind"] = "default" |
| 94 | meta['guide_info']['guide_default_id'] = job.guide_default_id |
| 95 | output_file_list.append(serialized) |
| 96 | |
| 97 | if job.guide_review_id: |
| 98 | ignore_id_list.append(job.guide_review_id) |
| 99 | serialized = job.guide_review.serialize_for_list_view() |
no test coverage detected