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