emcousin / pkp Goto Github PK
View Code? Open in Web Editor NEWWeb platform to attend parkour classes in Paris with the Parkour Paris association
Home Page: https://inscriptions.parkourparis.fr
Web platform to attend parkour classes in Paris with the Parkour Paris association
Home Page: https://inscriptions.parkourparis.fr
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.
Once you're done, you can either :
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 :
Subscription
: rails g model Subscription member:references year:integer fee:decimal
belongs_to :member, class_name: 'User'
has_many :courses_subscriptions, dependent: :destroy
has_many :courses, through: :courses_subscriptions
year
: integer
, required, should be the current year when the subscription is createdfee
: decimal
, required, >= 0, default 0, will be calculated depending on the number and type of coursesvalidates :member_id, uniqueness: { scope: :year}
has_many :courses_subscriptions, dependent: :destroy
has_many :subscriptions, through: :courses_subscriptions
has_many :members, through: :subscriptions
has_many :subscriptions, dependent: :destroy
has_many :courses, through: :subscriptions
CoursesSubscription
: rails g model CoursesSubscription course:references subscription:references
A CoursesSubscription :
belongs_to :course
belongs_to :subscription
With this type or architecture :
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.
/admin
, I want to see a blank page saying "Bienvenue, Administrateur!"As a User, I should be able to accesss the Admin Dashboard only if :
:authenticate_user!
in the controller, when trying to access the admin dashboard.admin
in the model User, using rails migrations. The value of admin
should be false
by defaultThis is a bug feature, so we are going to do it step by step
paid?
in the model subscription. For now, make it return false
unless
the current subscription is paid?
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.
As an Admin,
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 :
This ticket is about step 2 - part 2:
We need to add a new type of course, exclusively for women who prefer to train among themselves.
Therefore, we need to :
Adulte Féminin
rake db:seed
(the code is already written is courses.rake
). Just make sure it worksAs a Member, I would like to be able to click on a cross on top-right of an alert message to hide it when I'm done reading it
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.
signed_form
or medical certificate
, but on the Admin side and using the has_many_attached
ActiveStorage relationshipAs a member, I want to be able to edit my personal data
Profile
to the top menuYou will need 7 routes :
GET admin/courses
)GET admin/courses/:id
)GET admin/courses/new
)params
(POST admin/courses
)GET admin/courses/:id/edit
)params
(PATCH/PUT admin/courses/:id
)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
You will need to create a controller in app/controllers/admin/courses_controller.rb
index
, I want to have a variable @courses
that will be all the courses (Course.all
)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]
)new
, I want to have a variable @course
that will be a new instance of the model Course (Course.new
)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 coursesedit
, 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]
)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 coursesdestroy
, 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 coursesThe current registration form is this one : https://www.parkourparis.fr/s-inscrire
In this case, we need the member to subscribe in three steps :
This ticket is about step 1 :
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
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
As an Admin, I want to be able to confirm or archive a subscription from the subscription's details page, and not only from the subscriptions list page
You will need to create views for the action index
, show
, new
and edit
in the folder app/views/admin/courses/
.
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
)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.new
view, I want you to display a form which action will point to the admin/courses#create
controller actionedit
view, I want you to display a form which action will point to the admin/courses#update
controller actionBased on your work on #5, #6 and #7 :
As an Admin, I want to be able to Create, Read, Update and Destroy users.
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
:date
phone_number
: the member's phone number
:string
address
: the address of the member (street number and street name)
string
zip_code
: the zip code of the member
string
city
: the city of the member
string
country
: the country code of the member
string
contact_name
: the name of a person we can contact in case an accident happens
string
contact_phone_number
: the phone number of a person we can contact in case an accident happens
string
Contact relationship
: the relationship of a person we can contact in case an accident happens
string
Agreed To Publicity Right
boolean
avatar
:
string
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
null: false
in the migration file that will be generatedAs an admin, I would like to follow up a member's subscription. The subscription would have different steps
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
pending
, confirmed
or discarded
Rails provides Active Record Enum for that kind of feature. Give it a try!
As a Member, I want to be able to pay my subscription by credit or debit card
When you are clicking on a Member, I would like you to display the courses that member has subscribed to
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.
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
# 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
# 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
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
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
1 error prevented this subscription to be saved:
- You cannot choose more than 1 course per day
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 :
A subscription should not be valid if the user selected more than 1 course than happen the same day of the week
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
A subscription is invalid if it has courses that have the same weekday
I added rubocop
to the project. It is a gem that scans the code of the application and returns "offences" with recommendations about how to improve the code in tems of quality, security and performance.
I ran rubocop --autocorrect
and it fixed more that 120 offences.
Now run rubocop
and fix the remaining ones (a bit more than 20)
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 :
This ticket is about step 2 :
On the invoice of a subscription which fee is 175€, the price displayed is "175.0"
Can you change that so it shows "175,00 €" instead
As a Member, I should not be able to subscribe to courses when there are no more courses available.
A course
is available when:
course
's capacity
is greater than zerocourse
'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
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.
Remove from course
Based on #7, can you provide an interface to manage members the same way you currently manage courses?
The notice message is just a plain text. Let's use Bootstrap Alerts to make them look much nicer :
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 :
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 :
When submitting the form, it creates a subscription:
And I am redirected to a list of subscriptions. For each listed subscription I can see :
As an Admin, I want to be able to Create, Read, Update and Destroy courses.
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
:string
description
: the description of the course
:string
capacity
: the numbers of people who can subscribe to this course
integer
category
: the category of the courses
string
rails generate model Course title description type:integer category
null: false
in the migration file that will be generatedAs a Member, I should not be able to subscribe to courses when it is vacation time
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 actionbefore_action
callback like the one used hereTime.now.month
to know what month it isAs of now, a subscription is valid if there are courses in it. Let's improve that with the following rules :
As a member, when I login and land to my dashboard, I want to see the details of my current subscription for the current year, if I have one.
As a member, after I created my subscription, it needs to be completed. To do so, I need to:
This ticket is about uploading the signed 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:
container
, row
and col-xx-x
form-control
btn
and btn-xxxxxxx
As a Member, filling a form is a pain in the ass. Let's ease the member's pain by suggesting addresses when he/she starts filling the address input
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
As an admin, I want to be able to generate an invoice for a subscription
The invoice should as well:
POST
request containing the subscription's id to a dedicated controller action that should create the invoice for the subscription.id
provided in the params
Invoice
matching the following specifications
subscription_id
field should be set to nil
. This should be all declared in a has_one
relationship like this exampleParkour 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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.