For those wondering, I was successful in pushing my branch up to GitHub. There were 4 linting issues so it was not that bad. Simple things like adding a new line and removing unused imports.
There was a small change I needed to do when my teammate reviewed my code. I had to change the name of a file from ‘key.json’ to ‘credentials.json’. This would have been a 10-second fix but unfortunately, I had an issue with my computer and I lost my local copy of the repo. I needed to figure out how to get access to a remote branch. I followed these steps https://devconnected.com/how-to-switch-branch-on-git/ and I was able to select the branch I had been working on and submit the updated push request.
I realized while I was starting to implement the database functions for the skills page, I was typing (just change the applications to skills or to contacts):
db = firestore.client() applications = db.connection('applications')
This would be repeated many times so I decided to extract it into a function. I called it dbConn(). It takes the collection name and makes the connection to the database and retrieves the desired collection.
My first goal was to get the delete functionality working for the jobs page so I can implement it for the skills page next. My thought process was that I needed to target the job I want to delete. To make sure I get the functionality right, I selected one document from firebase and with its ID I was able to call a function that deletes it. I hard-coded an example like this to make sure it works properly:
def deleteJob(): dbConn('applications').document('3reZRCDZG98lW').delete() return 'deleted'
Now to make it work with the template and views. For the template in jobs.html, I added an indexing system that gives each entry in the table their jobID. This will make it so if they push the delete button, it will send that jobID to a new view. This view is
'/jobs/<jobID>/delete'
Now that I passed the jobID, I can call my deleteJob function and then redirect to the jobs page again but this time the entry will not show up on the table because it was successfully deleted.
After that, I started working on implementing the skills page. There were a lot of similar techniques that I used from the jobs/internship page.
Found a cool trick! You can add more data in the render_template:
return render_template('skills/skills.html', skills=skills, jobs=jobs)
This is how I was able to show all the jobs in the template.
The hardest part was figuring out how to make a drop-down of the positions and then adding that to the list of the application
{% for n in jobs%} <option>{{n.position}}-{{n.company}}</option> {%endfor%}
I made a delete modal because I wanted to reuse it for the other pages.
This post from StackOverflow really helped me with the ‘with’ feature of jinja2.
{% with val='skills/'+ skills[n].id + '/delete' %} {% include 'deleteModal.html'%} {% endwith %}
What’s happening here is I am including the delete modal but with the ‘val’ variable. The variable is string ‘skills/<skillID>/delete’
And in the deleteModal.html file, I have a link that goes to that route when clicked:
<a href={{val}}><button type="button" class="btn btn-danger">Delete</button></a>
I did the same for the jobs page.
Found out also, that if you add a job or skill and there is no such collection, the way my code is set up is that it will create it for you with the auto-ID setting. I like this but I am not sure if this will impose potential threats.