Backend¶
This section of the documentation contains a description of the django views used to do anything with users, CAMS, and projects.
Users/views.py¶
- users.views.clear_CAM(request)¶
- Function to clear a CAM. This function simply deletes all the blocks and links in a current CAM. After this function,
the user’s page will be refreshed and they will have a blank CAM. The CAM name/id does not change.
- users.views.create_participant(request)¶
This function is called if a user tries to create a participant account The first thing is to create a participant account using the participant signup form. Then, we determine whether or not a user wishes to join a project.
Functionality to create a user and assign them to a project. If the user wants to join a project and enters the correct password, then an account will be made with the following code: 1. Call views_CAM/upload_cam_participant 2. Call views_CAM/create_project_cam to create a CAM and associate it with a project 3. views_CAM/upload_cam_participant continues with uploading the initial project CAM to the user’s CAM if one exists
- users.views.create_random(request)¶
Create user with randomized username and password
- users.views.create_researcher(request)¶
Basic functionality to create a researcher. This also creates a blank CAM for the researcher.This is only called if the user specifically signs up as a researcher.
- users.views.delete_user(request)¶
Simple view to delete user
- users.views.export_CAM(request)¶
Function to export CAM data. We export the block and link information (i.e. what’s in the database) as individual csv files. The files are then zipped into a single file called username_CAM.zip.The file is then downloaded to the Downloads file via the Jquery/Ajax call that envokes this function.
- users.views.import_CAM(request)¶
Functionality to import a CAM. The workflos is as follows: 1 - Read in file from Jquery/Ajax call. This file is in the format of a zip file containing csvs for both the blocks and links. The input here is the output of the export_CAM function. 2 - Clear any blocks/links from the current CAM in case any exist 3 -
- users.views.makepdf(html)¶
Generate a PDF file from a string of HTML.
- users.views.settings(request)¶
This view is the user settings view. Depending of the request, we want to either show the user’s settings or change them. In either case, we re-render the same page with the final settings.
- users.views.signup(request)¶
This view accept deals with the account creation form. In POST mode, it accepts the account creation form, validates it, create the user in the DB if the form is valid. In GET mode, it renders the form template for the account registration: ‘registration/register.html’.
Block/views.py¶
- block.views.add_block(request)¶
Functionality to add a block to the databaase. This functionality is called from templates/Concept/concept_placement.html or templates/Concept/Initial_Placement. The Jquery/Ajax call passes all block information to django. The information is augmented to include any other relavent features (i.e. creator id). The block is then created in the database via the BlockForm form defined in block/forms.py. The complete block data is then passed back to the drawing canvas.
- block.views.delete_block(request)¶
Function to delete a block from the current CAM. The id of the block to be deleted is passed through the Jquery/Ajax call defined in templates/Concept/delete_block.html. After deleting the block all links associated with the block are deleted from the database. The function returns a list of those links so that the Jquery/Ajax call can delete from them the drawing canvas.
- block.views.drag_function(request)¶
Functionality to update a block’s position after it is dragged on the canvas. This call is invoked via a Jquery/Ajax call defined in templates/Concepts/drag_function.html. The function takes the new positions of the block and updates the current blocks position. Then each link associated with the block is collected and their information is passed back to the drawing canvas in order to be updated via a Jquery call.
- block.views.trans_slide_to_shape(slide_val)¶
Translate between slider value and shape
- block.views.update_block(request)¶
Function to update the information associated with a block. This is called whenever a block is modified (with the exception of being moved/dragged – See below for that function). This can be invoked either from templates/Concept/concept_placement.html or templates/Concept/Initial_Placement or templates/Concept/resize_function.html. The block data is taken from the Jquery/Ajax call. The block is updated using the block.update() command defined in block/model.py. The block data is returned to the Jquery call to update the drawing canvas.