mentorship-backend icon indicating copy to clipboard operation
mentorship-backend copied to clipboard

created early CLI prototype

Open bartekpacia opened this issue 5 years ago • 19 comments

Description

In my opinion, working with the backend using Postman isn't really a great experience. POST Register user with a real email, open mailbox and confirm, then POST login. And if you want to use many other endpoints, you also need JWT for a particular user. And that user sometimes needs to be an admin (when u perform admin-like things). Huh, a lot of boring and tedious work.

I've seen issue #275, then #78, and thought...let's do it! I decided to go with Click, as it's provided by Flask out-of-the-box (Flask uses it internally for its own stuff, too). It's also very cool. From an "architectural side" I use Blueprints. They fit this use case quite well and are fairly simple.

And here it is, an early CLI prototype. I really hope it makes its way to the merge with main branch. It will save a lot of time:)

Features:

  • dropping and creating database
  • populating database with initial data
  • creating, updating and removing users
  • easy listing of all users and specific user (by id, username and email)
  • listing, assigning and revoking admins
  • managing mentorship relations
  • managing tasks

To be added:

  • unit tests
  • some decent documentation

fixes #275, #78 (well, it will fix when it gets stable)

Type of Change:

  • Code
  • Quality Assurance
  • User Interface [I'm not sure here...CLI is kinda like UI for a developer)
  • Documentation

I think it's worth mentioning that I had to upgrade Flask dependency to 1.1.1. That's beacuse this very useful functionality is available since 1.1.0. And 1.1.0 messed some things that 1.1.1 fortunately fixed.

Code/Quality Assurance Only

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update (software upgrade on readme file)

How Has This Been Tested?

Tested manually, but as said above, this is an early prototype. Consider this whole things as unstable - no unit tests, functionality isn't guarranteed to work. Use at you own risk (in the worst case you'll nuke your local database).

How to use it? (Example)

  1. Make sure that virtualenv is activated.
  2. flask (yea, just type flask in the terminal)
  3. You'll see commands at the bottom
  4. Let's say you want to create a new user.
  5. flask user will show you methods available for managing users.
  6. You see that flask user create is what you need. Type it in the terminal.
  7. Follow the instructions on screen.
  8. User is added.
  9. Now let's display all users using flask user show -s. -s flag shows only essential data.

I encourage you to explore and try (and find inevitable bugs). I'll try to write some more examples or maybe even ~~record a short video tutorial on how to use it~~ demo/tutorial here

Checklist:

  • [ ] My PR follows the style guidelines of this project
  • [x] I have performed a self-review of my own code or materials
  • [ ] I have commented my code or provided relevant documentation, particularly in hard-to-understand areas (I will)
  • [ ] I have made corresponding changes to the documentation (I will)
  • [ ] Any dependent changes have been merged
  • [x] Update requirements.txt

Code/Quality Assurance Only

  • [x] My changes generate no new warnings
  • [ ] My PR currently breaks something (fix or feature that would cause existing functionality to not work as expected)
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes

PS Any feedback would be greatly appreciated. I'm coming from NodeJS-land and still feel quite new and uncertain in this astonishing Python-Flasky world.

PPS I'll squash the commits when we it gets approved by mentors.

bartekpacia avatar Dec 16 '19 00:12 bartekpacia

@isabelcosta I think it may interest you

bartekpacia avatar Dec 16 '19 00:12 bartekpacia

Sure, changed :)

bartekpacia avatar Dec 16 '19 20:12 bartekpacia

I've recorded video demonstration.

bartekpacia avatar Dec 21 '19 00:12 bartekpacia

@isabelcosta @BadduCoder I'd love to hear your opinion and suggestions 😄 (if you have time of course)

bartekpacia avatar Dec 27 '19 10:12 bartekpacia

@bartekpacia This is my first time looking and actually thinking about this, so I just watched your video and this is pretty amazing :) And I just love that this helps to create a set of users just from a JSON file. I feel that this will require some changes, I will review soon. Do you wish to continue with this issue, if I end up proposing changes?

I already learned new things from this PR.

isabelcosta avatar Mar 23 '20 20:03 isabelcosta

@isabelcosta Oh, this PR. I remember how much work I put into this:) happy to hear you like it. I'd love this to be developed further because it has the potential of saving many hours of rather tedious work (I remember I was using this very often during GCI for my private testing purposes).

I'll wait for your opinions and will try to find some time to polish this. Hopefully it'll make its way into master.

bartekpacia avatar Mar 23 '20 20:03 bartekpacia

i accidentaly closed👀

help

bartekpacia avatar Mar 23 '20 20:03 bartekpacia

I accidentally opened 👀

isabelcosta avatar Mar 23 '20 21:03 isabelcosta

hi @bartekpacia could you mind to resolve the conflicts in this PR so, that it can be ready to merge :)

robotjellyzone avatar May 20 '20 10:05 robotjellyzone

@robotjellyzone Sure, resolving now.

bartekpacia avatar May 23 '20 17:05 bartekpacia

I've spent 1 hour trying to setup dev env for this project, but some extremely strange bugs appear. Finally, I resolved it using GitHub's website editor, so I couldn't test it :/

bartekpacia avatar May 23 '20 18:05 bartekpacia

at least checks are passing🙏

bartekpacia avatar May 23 '20 18:05 bartekpacia

@isabelcosta any response on this? I'd really love to see this get merged. (It might need some testing & updates, but I'm willing to provide necessary help)

bartekpacia avatar Jul 16 '20 17:07 bartekpacia

just a ping @isabelcosta :)

bartekpacia avatar Aug 04 '20 18:08 bartekpacia

Closing this due to inacativity also author is not assigned to the issue .

vj-codes avatar Feb 20 '21 18:02 vj-codes

@vj-codes , I'd really like to finish this feature:) Please consider reopening and assigning me – I will try to work on it when I have time. Are there any hard limits on the duration of how long can a PR be worked on by an author?

bartekpacia avatar Feb 20 '21 19:02 bartekpacia

@bartekpacia suree I'll assign it to you! No limits on duration but you should update the progress or approx time required so the PR is not inactive otherwise it could be closed by someone again 👀

vj-codes avatar Feb 20 '21 19:02 vj-codes

@bartekpacia also there are some merge conflicts do solve them when you have time, thanks!

vj-codes avatar Feb 20 '21 19:02 vj-codes

That's great, thank you:)

bartekpacia avatar Feb 20 '21 19:02 bartekpacia

I'm looking at the list of all my PRs and this is one of the oldest ones. Unfortunately I don't see a chance on getting this merged, last change (d878a013060785a0a077ea16342707b501880827) was made more than a year ago, so I'm going to reluctantly close this PR. Maybe, hopefully, in the future someone will be willing to pick this up.

Good old Google Code-in times. Thanks to everyone involved!

bartekpacia avatar Dec 01 '23 23:12 bartekpacia