def edit_group(request, group_id): group = Group.objects.get(id=group_id) if not is_co_owner_or_staff(request.user, group): raise PermissionDenied() form = GroupCreationForm(request.POST) is_created_original = group.is_created read_form_field_boolean(group, form, 'is_created') read_form_field_string(group, form, 'group_description') read_form_field_string(group, form, 'group_short_description') read_form_field_string(group, form, 'group_location') read_form_field_string(group, form, 'group_name') if not request.user.is_staff: group.group_date_modified = timezone.now() group.save() merge_json_changes(ProjectLink, group, form, 'group_links') merge_json_changes(ProjectFile, group, form, 'group_files') merge_single_file(group, form, FileCategory.THUMBNAIL, 'group_thumbnail_location') # TODO #if is_created_original != group.is_created: #print('notifying group creation') #send_project_creation_notification(group) return group
def create_or_edit_group(request, group_id): form = GroupCreationForm(request.POST) if group_id is not None: group = Group.objects.get(id=group_id) else: group = Group.objects.create( group_creator=get_request_contributor(request), group_date_created=timezone.now(), group_name=form.data.get('group_name'), group_short_description=form.data.get( 'group_short_description'), group_description=form.data.get('group_description'), is_created=False) if not is_co_owner_or_staff(request.user, group): raise PermissionDenied() is_created_original = group.is_created read_form_field_boolean(group, form, 'is_created') project_fields_changed = False read_form_field_string(group, form, 'group_description') read_form_field_string(group, form, 'group_short_description') read_form_field_string(group, form, 'group_country') read_form_field_string(group, form, 'group_location') read_form_field_string(group, form, 'group_state') read_form_field_string(group, form, 'group_city') project_fields_changed |= read_form_field_string( group, form, 'group_name') read_form_field_string(group, form, 'group_url') read_form_fields_point(group, form, 'group_location_coords', 'group_latitude', 'group_longitude') if not request.user.is_staff: group.group_date_modified = timezone.now() group.save() merge_json_changes(ProjectLink, group, form, 'group_links') merge_json_changes(ProjectFile, group, form, 'group_files') project_fields_changed |= merge_single_file( group, form, FileCategory.THUMBNAIL, 'group_thumbnail_location') if project_fields_changed: group.update_linked_items() if is_created_original != group.is_created: send_group_creation_notification(group) return group
def create_or_edit_project(request, project_id): form = ProjectCreationForm(request.POST) if project_id is not None: project = Project.objects.get(id=project_id) else: project = Project.objects.create( project_creator=get_request_contributor(request), project_name=form.data.get('project_name'), project_date_created=timezone.now(), is_created=False ) if not is_co_owner_or_staff(request.user, project): raise PermissionDenied() is_created_original = project.is_created read_form_field_boolean(project, form, 'is_created') read_form_field_string(project, form, 'project_description') read_form_field_string(project, form, 'project_description_solution') read_form_field_string(project, form, 'project_description_actions') read_form_field_string(project, form, 'project_short_description') read_form_field_string(project, form, 'project_location') read_form_field_string(project, form, 'project_country') read_form_field_string(project, form, 'project_state') read_form_field_string(project, form, 'project_city') read_form_field_string(project, form, 'project_name') read_form_field_string(project, form, 'project_url') read_form_fields_point(project, form, 'project_location_coords', 'project_latitude', 'project_longitude') read_form_field_tags(project, form, 'project_issue_area') read_form_field_tags(project, form, 'project_stage') read_form_field_tags(project, form, 'project_technologies') read_form_field_tags(project, form, 'project_organization') read_form_field_tags(project, form, 'project_organization_type') if not request.user.is_staff: project.project_date_modified = timezone.now() project.save() merge_json_changes(ProjectLink, project, form, 'project_links') merge_json_changes(ProjectFile, project, form, 'project_files') merge_json_changes(ProjectPosition, project, form, 'project_positions') merge_single_file(project, form, FileCategory.THUMBNAIL, 'project_thumbnail_location') if is_created_original != project.is_created: print('notifying project creation') send_project_creation_notification(project) return project
def edit_project(request, project_id): project = Project.objects.get(id=project_id) if not is_co_owner_or_staff(request.user, project): raise PermissionDenied() form = ProjectCreationForm(request.POST) is_created_original = project.is_created read_form_field_boolean(project, form, 'is_created') read_form_field_string(project, form, 'project_description') read_form_field_string(project, form, 'project_short_description') read_form_field_string(project, form, 'project_location') read_form_field_string(project, form, 'project_name') read_form_field_string(project, form, 'project_url') read_form_field_tags(project, form, 'project_issue_area') read_form_field_tags(project, form, 'project_stage') read_form_field_tags(project, form, 'project_technologies') read_form_field_tags(project, form, 'project_organization') if not request.user.is_staff: project.project_date_modified = timezone.now() project.save() merge_json_changes(ProjectLink, project, form, 'project_links') merge_json_changes(ProjectFile, project, form, 'project_files') merge_json_changes(ProjectPosition, project, form, 'project_positions') merge_single_file(project, form, FileCategory.THUMBNAIL, 'project_thumbnail_location') if is_created_original != project.is_created: print('notifying project creation') send_project_creation_notification(project) return project