GithubHelp home page GithubHelp logo

emcousin / pkp Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 4.1 MB

Web platform to attend parkour classes in Paris with the Parkour Paris association

Home Page: https://inscriptions.parkourparis.fr

Ruby 50.51% JavaScript 3.97% HTML 44.25% SCSS 1.18% Shell 0.04% Procfile 0.05%
paris parkour

pkp's People

Contributors

dependabot[bot] avatar depfu[bot] avatar emcousin avatar silvadaniele avatar

Watchers

 avatar  avatar

pkp's Issues

Code review - PR #32

This Pull Request #32 seems to do a bunch of things, but is poorly documented.
Your task is to review the code, add comments upon the lines you think require clarification.

TODO :

  • Checkout the branch related to this PR
  • Make sure it works
  • If it doesn't work, comment on the PR what corrections need to be done
  • Comment with how you think the code could be written better

Once you're done, you can either :

  • Request changes, detailing what changes you would like to be implemented
  • Comment
  • Approve

Subscription - model creation

As an Admin, I want to assign or to de-assign a member to one or several courses though subscriptions

An Admin can subscribe a member to one of more courses. To do so :

  • They initiate the creation of a subscription and assign it to the member
  • For the subscription they are about to create, they will assign one or more existing courses
  • When they create the subscription, it will compute automatically its fee

Model creation : Subscription : rails g model Subscription member:references year:integer fee:decimal

  • A subscription :
    • belongs_to :member, class_name: 'User'
    • has_many :courses_subscriptions, dependent: :destroy
    • has_many :courses, through: :courses_subscriptions
    • has attributes :
      • year: integer, required, should be the current year when the subscription is created
      • fee: decimal, required, >= 0, default 0, will be calculated depending on the number and type of courses
    • A Member should not have more than one subscription per year : validates :member_id, uniqueness: { scope: :year}
    • has references (relationship attributes) :
      • member_id: the id of the user
  • A course :
    • has_many :courses_subscriptions, dependent: :destroy
    • has_many :subscriptions, through: :courses_subscriptions
    • has_many :members, through: :subscriptions
  • A member
    • has_many :subscriptions, dependent: :destroy
    • has_many :courses, through: :subscriptions

Join model creation : CoursesSubscription : rails g model CoursesSubscription course:references subscription:references

A CoursesSubscription :

  • belongs_to :course
  • belongs_to :subscription

Summary

With this type or architecture :

  • A member will be able to subscribe once per year to multiple courses via one subscription
  • A subscription will be related to multiple courses
  • A course can be the target of multiple subscriptions
  • We will be able to list the member's courses, and for a given course, the members that are subscribed to it for a given year

Course form - enhancements

Based on the following screenshot, you are tasked on making the course form look better.
Any initiative from your side is also welcome

image

Admin Dashboard

As an Admin, I want to have a Admin Dashboard page when I navigate to /admin.
For now, we do not yet restrict the access of this page upon being connected.

  • When navigating to /admin, I want to see a blank page saying "Bienvenue, Administrateur!"

Tips

  • You will need to define a route, a controller, and a view

Access the Admin Dashboard only if I am a connected admin

As a User, I should be able to accesss the Admin Dashboard only if :

  • I am a connected user
  • I am an Admin

Tips

  • Use the gem Devise. Force the authentication with :authenticate_user! in the controller, when trying to access the admin dashboard.
  • Add a boolean column admin in the model User, using rails migrations. The value of admin should be false by default
  • If I am connected but I am not an admin, I should not be able to access the admin dashboard

Member - Pay my subscription - Step 1

This is a bug feature, so we are going to do it step by step

Step 1

  • Add an instance method paid? in the model subscription. For now, make it return false
  • As a member who just subscribed to a course, Add a button "Payer" unless the current subscription is paid?

Admin - Ability to preview then generate an invoice

As an admin, I want to be able to preview an subscription's invoice before I generate it.
I should not be able to preview this invoice if the related subscription has not been paid.

Details

As an Admin,

  • When I navigate to the details page of a member's paid subscription that has not an invoice yet, I want to be able to click on a button "Prévisualiser la facture" to preview the invoice.
  • Clicking on that button should redirect me to a dedicated view that represents the invoice of my subscription, in HTML
  • At the bottom of this view, there should be a button "Générer la facture".
  • When clicking on that button, there should be a confirm popup "Vous êtes sûr ? Vous ne pourrez pas modifier la facture une fois générée"
  • On confirming, a POST request should be sent that trigger the generation to PDF of the invoice

Member - Subscribe to one or multiple courses - Step 2.5

The current registration form is this one : https://www.parkourparis.fr/s-inscrire
In this case, we need the member to subscribe in three steps :

  1. Creating an account.
  2. Choosing the courses to subscribe to.
  3. Be redirected to a page that displays confirmation message saying that the subscription was done successfully

This ticket is about step 2 - part 2:

  • When I click on the button "Choose my courses" on the home page, it navigates to a new page with a form to select the category of course I want.
  • This form only contains a select input. When I select the course category and submit the form, I should be redirected to another page. This other page contains a form with a list of the courses of the category I selected previously. They are presented as checkboxes
  • When I submit that other form : severak things happen on the backend

Add a new category of course

We need to add a new type of course, exclusively for women who prefer to train among themselves.

Therefore, we need to :

  • Add a new category to the course categories list. It will be named Adulte Féminin
  • Generate this course by default when running rake db:seed (the code is already written is courses.rake). Just make sure it works

Admin - Issue a credit note to correct a wrong invoice

As an admin, if I generate an invoice that turns out to be wrong for any reason, I should not be able to modify my invoice, as it is forbidden by law.
Instead, I should be able to create a credit_note, which is a document that corrects the existing invoice.

Rules

  • I should not be able create a credit note if the subscription does not have an invoice
  • If the subscription has an invoice, then I should be able to create as many credit notes as I want for that given subscription

Tips

Member - Edit my personal data

As a member, I want to be able to edit my personal data

  • Add a link Profile to the top menu
  • When you click on that link, it should navigate to a dedicated page with a form to edit your personal data
  • When you submit the form, if should update your personal data, redirect you to the same page with a flash confirmation message
  • If the submit fails, the page should be rerendered with the appropriate error messages expa-laining why

CRUD Courses - Routes and controller creation

Route creation

You will need 7 routes :

  • Display a list of courses (GET admin/courses)
  • Display a particular course (GET admin/courses/:id)
  • Display a form that will create a course on submit (GET admin/courses/new)
  • Create a course from a submitted form's request's params (POST admin/courses)
  • Display a form that will update a course on submit (GET admin/courses/:id/edit)
  • Update an existing course from a submitted form's request's params (PATCH/PUT admin/courses/:id)
  • Destroy a particular course (DELETE admin/courses/:id)

Each of these routes will point to a controller action :

  • GET admin/courses/:id will point to admin/courses#index
  • GET admin/courses/:id will point to admin/courses#show
  • GET admin/courses/new will point to admin/courses#new
  • POST admin/courses will point to admin/courses#create
  • GET admin/courses/:id/edit will point to (admin/courses#edit)
  • PATCH/PUT admin/courses/:id will point to (admin/courses#update)
  • DELETE admin/courses/:id will point to (admin/courses#destroy)

Note : VERB controller_name#action_name

You can generate the 7 corresponding courses by simply typing in config/routes.rb, as explained in this documentation : https://guides.rubyonrails.org/routing.html#crud-verbs-and-actions :

# config/routes.rb
namespace :admin do
  resources :courses
end

Controller creation

You will need to create a controller in app/controllers/admin/courses_controller.rb

  • In the action index, I want to have a variable @courses that will be all the courses (Course.all)
  • In the action show, I want to have a variable @course that will be the course corresponding to the id of the course present in the params (Course.find_by(id: params[:id])
  • In the action new, I want to have a variable @course that will be a new instance of the model Course (Course.new)
  • In the action create, I want to have a variable @course that will be an instance of the model Course based of the params of the request (Course.create(course_params)) and be redirected to the list of courses
  • In the action edit, I want to have a variable @course that will be the course corresponding to the id of the course present in the params (Course.find_by(id: params[:id])
  • In the action update, I want to have a variable @course that will be the course corresponding to the id of the course present in the params (Course.find_by(id: params[:id]). I want this @course to be updated with course_params, and be redirected to the list of courses
  • In the action destroy, I want to have a variable @course that will be the course corresponding to the id of the course present in the params (Course.find_by(id: params[:id]). I want to destroy this @course (@course.destroy) and be redirected to the list of courses

Member - Subscribe to one or multiple courses - Step 1

The current registration form is this one : https://www.parkourparis.fr/s-inscrire
In this case, we need the member to subscribe in three steps :

  1. Creating an account.
  2. Choosing the courses to subscribe to.
  3. Be redirected to a page that displays confirmation message saying that the subscription was done successfully

This ticket is about step 1 :

Update Translations

  • Change Users for Membres
  • Change Subscriptions for Inscriptions
    • Attention: there's a typo in the code, one of them is written Suscriptions
  • Change Sign Out for Déconnexion
  • Change Space Admin for Admin

image

Member - Receive an email confirming that my subscription was successful

As a Member, when I land on the confirmation page, I should also receive an email with the details of my subscription and the instructions to finalize it.

Hint : the email is already coded and working when subscribing via the Wix website. The objective here is to adapt it by providing the email with the input from the subscription of the member

Admin - Paginate subscriptions

Parkour Paris has hundreds of ubscription every year. Displaying all of them at once in the same page is a performance bottleneck we need to solve.

One way to help is pagination. When navigating to /admin/subscriptions, I would like the subscriptions to be displayed per pages of 50. Then, at the bottom of the page, I would like to be able ot have a pagination breadcrumb allowing me to navigate to the first page, the previous page, the next page, or the last page

This issue is similar to #76

CRUD courses - view creation

Views

You will need to create views for the action index, show, newand edit in the folder app/views/admin/courses/.

  • In the index view, I want you to list the courses based on the object @courses. For each course, there will be a link to show the course, to edit the course, and to delete the course. On top of this page there will also be button that will route to the page to create a new course (new)
  • In the show view, I want you to list the course's details. There will be a link to edit the course, and to delete the course.
  • In the new view, I want you to display a form which action will point to the admin/courses#create controller action
  • In the edit view, I want you to display a form which action will point to the admin/courses#update controller action

Admin - CRUD Members

Based on your work on #5, #6 and #7 :

As an Admin, I want to be able to Create, Read, Update and Destroy users.

Model User

We are going to use the already-existing User model.

We only need to add more attributes to this model :

  • birthdate : the date of birth of the member
    • Type :date
    • Required
  • phone_number : the member's phone number
    • Type :string
    • Required
    • Has to match a the valid french format (consider using the gem 'phonelib')
  • address : the address of the member (street number and street name)
    • Type : string
    • Required
  • zip_code : the zip code of the member
    • Type : string
    • Required
  • city : the city of the member
    • Type : string
    • Required
  • country : the country code of the member
    • Type : string
    • Required
  • contact_name : the name of a person we can contact in case an accident happens
    • Type : string
    • Required
  • contact_phone_number : the phone number of a person we can contact in case an accident happens
    • Type : string
    • Required
    • Has to match a the valid french format (consider using the gem 'phonelib')
  • Contact relationship : the relationship of a person we can contact in case an accident happens
    • Type : string
    • Required
    • Is limited to a list of valid values:
      • Père
      • Mère
      • Tuteur / Tutrice
      • Conjoint(e)
      • Frère
      • Sœur
      • Grand-père
      • Grand-mère
      • Oncle
      • Tante
      • Cousin(e)
      • Ami(e)
      • Autre
        -Agreed To Publicity Right
    • Type : boolean
    • Required
    • Default : false
  • avatar :

Tips

  • You can generate a migration this way : rails generate migration AddAttributesToUsers birthdate:date phone_number address zip_code city country contact_name contact_phone_number contact_relationship agreed_to_publicity_right:boolean avatar
  • Make sure that the fields that are required are set to null: false in the migration file that will be generated

Admin - Manage a member's subscription per status

As an admin, I would like to follow up a member's subscription. The subscription would have different steps

  • Pending : the member subscribed to some courses. This is the status by default
  • Confirmed : the admin confirms the subscription. That means the member is allowed to attend the courses. This usually happens when the members actually paid the courses and that Parkour Paris actually received the payment
  • Discarded : the member did not pay the courses before the due date and the admin discards their subscription

For each subscription in the admin panel, the admin can perform the following actions :

  • Confirmer : When the admins clicks on this button, the subscription's status should be updated to confirmed
  • Rejeter : When the admins clicks on this button, the subscription's status should be updated to discarded

Validation rules

  • The subscription's status must be present
  • The subscription cannot have a status other than pending, confirmed or discarded

Tips

Rails provides Active Record Enum for that kind of feature. Give it a try!

Admin - Members list page improvements

Can you provide some improvements to the admin members page so that :

  • The avatar of each member is shown at the left of their name
  • The birthdate is displayed
  • The action buttons are closer to each other

image

When viewing a member, display the course they subscribed to

When you are clicking on a Member, I would like you to display the courses that member has subscribed to

Tips

You will need to work with Active Record relations again. Look at the relations present in the app/models.user.rb file and deduce the way you can list the courses of the user.

[DRY] - Refactor the code that creates a subscription

The code to create a subscription as an admin for a member is nearly identical to the code to create your own subscription as a member

Here is a good practice in the world of ruby : DRY, for Don't Repeat Yourself.

The idea is to factor the identical code into a dedicated class, and use this class in both controllers.

You can inspire yourself from the following example

Before refactoring

# foo1_controller.rb
class Foo1Controller < ApplicationController
  def create
    @foo = Foo.new(foo_params)
    @foo.do_stuff
    if @foo.save
       @foo.do_more_stuff
    end

    redirect_to foo1_path
  end
end
# foo2_controller.rb
class Foo2Controller < ApplicationController
  def create
    @foo = Foo.new(foo_params)
    @foo.do_stuff
    if @foo.save
       @foo.do_more_stuff
    end

    redirect_to foo2_path
  end
end

After refactoring

# foo1_controller.rb - refactored
class Foo1Controller < ApplicationController
  def create
    @foo = CreateFooService.new(foo_params).perform!
    redirect_to foo1_path
  end
end
# foo2_controller.rb - refactored
class Foo2Controller < ApplicationController
  def create
    @foo = CreateFooService.new(foo_params).perform!
    redirect_to foo2_path
  end
end
# app/services/create_foo_service.rb

class CreateFooService
  def initialize(foo_params)
    @foo_params = foo_params
  end

  def perform!
     foo = Foo.new(@foo_params)
     foo.do_stuff
     if foo.save
       foo.do_more_stuff
     end

     return foo
  end
end

Display an error message when the subscription is not valid

What is happening

As a member,
When I want to subscribe to courses and I select a wrong combination of courses, or when I already have a subscription,
then the form resets itself without obvious explanantion

What should happen

As a member,
When I want to subscribe to courses and I select a wrong combination of courses, or when I already have a subscription,
then I an explanation why my subscription in invalid should be displayed

Example

1 error prevented this subscription to be saved:

  • You cannot choose more than 1 course per day

Admin - View the detail of a member's subscription

As an admin, I would like to be able to view the details of a member's subscription. Especially, I want to be able to :

  • Check if the subscription has been paid
  • Download their signed form, if there is one
  • Download their medical certificate, if there is one

Validate subscription per course day

A subscription should not be valid if the user selected more than 1 course than happen the same day of the week

Tips

Add a field weekday to the table courses

We don't have a clean way to know on which day a course happens. Let's fix that by adding a field weekday to the table courses. This field should be an integer, required, and valid only between 1 and 7 included ; 1 reprensenting monday, and 7 representing sunday

Validate the subscription

A subscription is invalid if it has courses that have the same weekday

Member - Subscribe to one or multiple courses - Step 2

The current registration form is this one : https://www.parkourparis.fr/s-inscrire
In this case, we need the member to subscribe in three steps :

  1. Creating an account.
  2. Choosing the courses to subscribe to.
  3. Be redirected to a page that displays confirmation message saying that the subscription was done successfully

This ticket is about step 2 :

  • When I submit the form to create my account, I want to be redirected to simple page that says "Welcome, #{USER_FIRST_NAME}!".
  • Under that welcome message, there will be a central button "Choose my courses". Clicking on that button will navigate to the subscription creation page, that we will make in another ticket

Prevent members from subscribing from courses when there are no courses available

As a Member, I should not be able to subscribe to courses when there are no more courses available.

Notes

  • A course is available when:

    • the course's capacity is greater than zero
    • the total of subscriptions that are not archived related to the courses for the current year is lesser than the course's capacity
  • No more courses available mean each and every course is unavailable. If at least one course is still available, the members can still use the subscription form.

  • If no more courses are available and I try to subscribe to a new course, I should be redirected to a new page that explains that everything is full. Currently, it is this page

Tips

  • Inspire yourself from the tips of #97

Let's make the app more beautiful now

  • Using Bootstrap and CSS, let's make the forms and the tables centered
  • For each course, list the members of the current year that subscribed to this course

Remove a member from a course

As an Admin, when I am viewing the details of a member and their subscriptions to courses, I want to be able to remove a member from a course.

  • For each course listed of a member, add a button Remove from course
  • Clicking on this button will display a confirm popup "Are you sure you want to remove [MEMBER FULL NAME] from [COURSE NAME] ?"
  • Confirming will have to remove the course from the member's subscription
  • You will be redirected to the same page

Compute subscription fee automatically

When a subcription is created, we want to automatically compute the fee that the user will need to pay. The fee's amount will depend on the courses the user selected, based on the following rules :

  • If the user selected 1 course Adulte, the fee is 175
  • If the user selected 2 courses Adulte, the fee is 285
  • If the user selected 3 courses Adulte, the fee is 330
  • If the user selected 1 course Adolescent, the fee is 175
  • If the user selected 2 courses Adolescent, the fee is 300
  • If the user selected 1 course Kidz the fee is 175

Admin - Subscribe an existing member to multiple courses

As an Admin, I would like to subscribe an existing member to one or multiple courses
For that, I would like a form in which the admin will be able to :

  • Select the member to subscribe among the existing members
  • Select the courses to subscribe among the existing courses

When submitting the form, it creates a subscription:

  • With the year automatically set as the current year
  • With the fee automatically set as 0 (this is temporary)

And I am redirected to a list of subscriptions. For each listed subscription I can see :

  • The member
  • The fee

CRUD courses - Model creation

As an Admin, I want to be able to Create, Read, Update and Destroy courses.

Model Creation

For that, I would like the courses to be managed in the databased via a table courses, that would be mapped by an ActiveRecord model Course.

A Course should have the following attributes :

  • title : the title of the course
    • Type :string
    • Required
    • Example : Lundi Adulte Mixte
  • description : the description of the course
    • Type :string
    • Optional
  • capacity : the numbers of people who can subscribe to this course
    • Type : integer
    • Required
  • category : the category of the courses
    • Type : string
    • Required
    • Only these values are possible :
      • Adulte
      • Adolescent (13 - 15 ans)
      • Adolescent (10 - 12 ans)
      • Kidz (6 - 9 ans)

Tips

  • You can generate the model Course with its attributes this way : rails generate model Course title description type:integer category
  • Make sure that the fields that are required are set to null: false in the migration file that will be generated

Prevent members from subscribing to courses when it's vacation time

As a Member, I should not be able to subscribe to courses when it is vacation time

Notes

  • Vacation time is every year, from July 1 to August 31, included
  • If it's vacation time and I try to subscribe to a new course, I should be redirected to a new page that explains that the courses will start in September. Currently, it is this page

Tips

  • Try to create the dedicated page first. In order to organize everything nicely, your page will have a dedicated route, controller and view. The controller should be named vacations_controller and the action index. The view should be in views/vacations.index.html.erb. The route should be declared in routes.rb accordingly, via the resources helper and should allow only the index REST action
  • You will need to edit the (Dashboard) SubscriptionsController to redirect to that new page if it is vacation time. To do so, you can use a before_action callback like the one used here
  • Checking that it is vacation time means checking than the month is either July or August. You can use Time.now.month to know what month it is

Validate subscription per course category

As of now, a subscription is valid if there are courses in it. Let's improve that with the following rules :

  • A subscription is invalid unless the courses selected are of the same category
  • A subscription is invalid if more than 3 courses are selected

Member - Upload my signed subscription form

As a member, after I created my subscription, it needs to be completed. To do so, I need to:

  • upload a medical certificate after visiting a doctor
  • sign the form I received by email and upload it
  • Pay the subscription

This ticket is about uploading the signed form

Design - Login, registration, and forgot-password form

Let's make these devise forms better-looking, using Bootstrrap.
In the previous tickets, you already generated the Devise views, that are in app/views/devise.

Using Bootstrap, any other CSS library or even plain CSS, I would like you to make these form better looking. Here are some examples using Bootstrap:

  • Forms centered in the top-moddle of the page, using the CSS classes container, row and col-xx-x
  • the fields looking bigger, using the CSS class form-control
  • The buttons looging bigger, using the CSS classes btn and btn-xxxxxxx
  • Anything else that you will find relevant to make these forms better looking in general

Admin - Paginate members

Parkour Paris has hundreds of members every year. Displaying all of them at once in the same page is a performance bottleneck we need to solve.

One way to help is pagination. When navigating to /admin/users, I would like the members to be displayed per pages of 50. Then, at the bottom of the page, I would like to be able ot have a pagination breadcrumb allowing me to navigate to the first page, the previous page, the next page, or the last page

Tips

  • No need to build the entire pagination system from scratch. There are plenty of libraries that do the job just fine. Search and find one, assess its relevance (is it safe, recently updated?) and use it

Admin - Invoicing system

As an admin, I want to be able to generate an invoice for a subscription

  • Only if the subscription has been paid
  • There should be only one invoice per subscription
  • You cannot regenerate an invoice once it is generated (it is forbidden by law!)

The invoice should as well:

  • Belongs to a subscription
  • Have one attached file. This file will a PDF generated by our application and will contain all the invoice's details.

TODO

View

  • In the admin panel, when viewing the subscription details, add a button "Générer une facture"
  • Clicking on that button should send a POST request containing the subscription's id to a dedicated controller action that should create the invoice for the subscription.

Controller behaviour

  • The controller should find the subscription based on its id provided in the params
  • Then, it should create an invoice
  • if the invoice is successfully created, it redirects back to the subscription details, with a success message "Facture générée"
  • if the invoice fails to be created, it redirects back to the subscription details, with an alert message "La facture n'a pas pu être générée"

Model

  • Create a model Invoice matching the following specifications
    • An invoice should belong to a subscription
    • A subscription should only have one invoice. If a subscription is destroyed, its related invoice should not be destroyed, but its subscription_id field should be set to nil. This should be all declared in a has_one relationship like this example

Admin - Search members by full name

Parkour Paris has hundreds of members every year. Displaying all of them at once in the same page is a performance bottleneck we need to solve.

One way to help is search. When navigating to /admin/users, I would like to have on top of the page, a search bar in which I can search members by their first name or last name. The results would be the corresponding matches of my search.

Tips

  • I would like the parameters of my search to be saved in the URL every time. That means, if I refresh my page using Ctrl + R, I get the exact same page with the exact same results without having to re-do my search

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.