It has been a while since my last #100DaysOfCode update. I haven’t been exactly working every day on these challenges, but I did some work towards it for the past 10 non-consecutive days.
Yesterday when I added the feature to email users multiple day’s entries, there was one small bug that I missed. The subject like still showed the first entry’s date. I fixed it by making sure that if we are emailing a single day’s entry, it showed one date and if we are emailing more than a day’s entry, it will show the from and to dates.
Since I try to make most of the interaction with the web app through the URL, I wanted to add an easier way to get the last N entries. I added a new view function which displays the last N entries.
The user has to visit /entry/last/N/ to display the N days’ entries. This is in fact quite simple to implement after I have implemented the custom date range filters yesterday. I just calculate the from and to date based on the last N dates and I redirect the user to the right filters.
Today I completed the custom date ranges that I talked about in yesterday’s post. Instead of just displaying a day/month/year, you can choose a from and a to date range and all entries that were created in that range will be displayed.
I ended up using GET parameter to get the date ranges. You have to form the URL as /entry/?from=2017-04-01&to=2017-04-26 to display all entries from 1st of April till 26th of April (both inclusive).
Today I spent most of the time refactoring the entry view function. Moving the save functionality into it’s own separate function.
This refactoring is needed because I have to add a way to get all entries that were added between two dates. The entry view function is becoming too big and I definitely need a cleanup for implementing this new feature better.
I have been thinking hard about how best to create the URL for this and since URL. Currently the URL structure is something like /entry/YYYY/MM/DD/ and you can remove the DD and MM part to show entries for a month and an year respectively. But I want the user to be able to see all entries from a date till another date.
Use an URL like /entry/YYYY/MM/DD/to/YYYY/MM/DD/. While this does make it easy to remember and type, it does make writing code to handle all the different combinations hard. What is the user wants to put in just /entry/YYYY/MM/to/YYYY/MM ? And what if he gives date in from and no date in the to section?
Accept the from and to as GET params – like /entry/?from=YYYY-MM-DD&to=YYYY-MM-DD. This makes it easier to code and will introduce a lot lesser bugs. But the downside is bad URL design.
These are the two options I can think of and I think I will go with the second option for it’s ease of implementation.
Thinking of the next important feature that would be asked to make others to use the app is the Password Change screen. Right now, we have 8 users on the app and it was I who set everyone’s password. But soon they would want to change it to something more secure.
So I quickly wrote a view function which will display a password change form and will also change it if the password and confirm_password fields match. It also logs the user out on successful password change. All of this was made easy because of Flask-Login.
Tomorrow I will be back to my home and would have a much better internet and more time to program.
Previously all entries were insert only, no edits were possible. I thought there shouldn’t be a way to edit the history (or the future) for that matter. So I went with an insert only design. But within 2 days of using the software, I found editing entries is very much needed.
The code to allow editing is easy to implement and all you have to do is, pass ?edit=true as GET params to a page and you will be shown the edit screen.
I think I might restrict edits to only today’s entries instead of being able to edit any arbitrary day’s entries. But that is for a future release.
But for milestone v0.2, I would have to probably remove couple of issues and mark the milestone as complete. Next week, when I go back to mainland, I will add more features.