|
27 | 27 | from .field_list import required_metadata
|
28 | 28 | from .filters import CollectionFilter
|
29 | 29 | from .forms import CollectionForm, ImageMetadataForm, DescriptiveMetadataForm, UploadForm, collection_send
|
30 |
| -from .models import UUID, Collection, ImageMetadata, DescriptiveMetadata, Project, ProjectPeople, People, Project, EventsLog, Contributor, Funder, Publication, Instrument, Dataset, Specimen, Image, Sheet |
| 30 | +from .models import UUID, Collection, ImageMetadata, DescriptiveMetadata, Project, ProjectPeople, People, Project, EventsLog, Contributor, Funder, Publication, Instrument, Dataset, Specimen, Image, Sheet, Consortium, ProjectConsortium |
31 | 31 | from .tables import CollectionTable, DescriptiveMetadataTable, CollectionRequestTable
|
32 | 32 | import uuid
|
33 | 33 | import datetime
|
@@ -119,6 +119,7 @@ def modify_user(request, pk):
|
119 | 119 | else:
|
120 | 120 | pi = False
|
121 | 121 | person = People.objects.get(auth_user_id_id = pk)
|
| 122 | + |
122 | 123 | all_project_people = ProjectPeople.objects.filter(people_id_id=person.id).all()
|
123 | 124 | for project_person in all_project_people:
|
124 | 125 | try:
|
@@ -202,8 +203,14 @@ def manageProjects(request):
|
202 | 203 | for row in project_person:
|
203 | 204 | project_id = row.project_id_id
|
204 | 205 | project = Project.objects.get(id=project_id)
|
205 |
| - allprojects.append(project) |
206 |
| - |
| 206 | + allprojects.append(project) |
| 207 | + |
| 208 | + project_consortia = ProjectConsortium.objects.filter(project_id=project.id).all() |
| 209 | + project.short_names = [] |
| 210 | + for c in project_consortia: |
| 211 | + short_name = Consortium.objects.get(id=c.id).short_name |
| 212 | + project.short_names.append(short_name) |
| 213 | + project.short_names = ', '.join(project.short_names) |
207 | 214 | return render(request, 'ingest/manage_projects.html', {'allprojects':allprojects, 'pi':pi})
|
208 | 215 |
|
209 | 216 | # this functions allows pi to see all the collections
|
@@ -232,30 +239,39 @@ def project_form(request):
|
232 | 239 | current_user = request.user
|
233 | 240 | people = People.objects.get(auth_user_id_id = current_user.id)
|
234 | 241 | project_person = ProjectPeople.objects.filter(people_id = people.id).all()
|
| 242 | + consortia = Consortium.objects.all |
235 | 243 | for attribute in project_person:
|
236 | 244 | if attribute.is_pi:
|
237 | 245 | pi = True
|
238 | 246 | else:
|
239 | 247 | pi = False
|
240 |
| - return render(request, 'ingest/project_form.html', {'pi':pi}) |
| 248 | + return render(request, 'ingest/project_form.html', {'pi':pi, 'consortia':consortia}) |
241 | 249 |
|
242 | 250 | # takes the data from project_form
|
243 | 251 | @login_required
|
244 | 252 | def create_project(request):
|
245 | 253 | new_project = json.loads(request.body)
|
| 254 | + print(new_project) |
246 | 255 | items = []
|
247 | 256 | for item in new_project:
|
248 | 257 | items.append(item['funded_by'])
|
249 |
| - items.append(item['is_biccn']) |
250 | 258 | items.append(item['name'])
|
251 |
| - |
| 259 | + items.append(item['consortia_ids']) |
| 260 | + |
252 | 261 | funded_by = item['funded_by']
|
253 |
| - is_biccn = item['is_biccn'] |
254 | 262 | name = item['name']
|
255 |
| - |
| 263 | + consortia_ids = item['consortia_ids'] |
| 264 | + |
256 | 265 | # write project to the project table
|
257 |
| - project = Project(funded_by=funded_by, is_biccn=is_biccn, name=name) |
| 266 | + project = Project(funded_by=funded_by, name=name) |
258 | 267 | project.save()
|
| 268 | + |
| 269 | + proj_id = project.id |
| 270 | + |
| 271 | + for c in consortia_ids: |
| 272 | + project_consortium = ProjectConsortium(project_id=proj_id, consortium_id=c) |
| 273 | + project_consortium.save() |
| 274 | + |
259 | 275 |
|
260 | 276 | # create a project_people row for this pi so they can view project on pi dashboard
|
261 | 277 | project_id_id = project.id
|
|
0 commit comments