Giter VIP home page Giter VIP logo

anitab-org / anitab-forms-backend Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 58.0 1.85 MB

AnitaB Forms (backend), an application to process smaller 4-week or full day programs to contribute to open source projects. Similar to GSoC, Outreachy, or RGSoC. This is the backend app.

License: GNU General Public License v3.0

Python 90.61% Dockerfile 0.16% Shell 0.71% JavaScript 7.18% CSS 1.35%
python backend django-rest-framework hacktoberfest

anitab-forms-backend's Introduction

Anitab Forms Backend

Build Status project chat License: GPL v3 Open Source Love Maintenance PRs Welcome codecov

AnitaB Forms is an application that simplifies the processing and selection procedure of Open Source Programs of AnitaB.org Open Source or other third-party programs. This is the Backend repo for OSP.

Tech Stack

  • Django 3.0.7
  • Django REST Framework 3.11.0
  • Python 3.7+

API Documentation

Setup

To setup the project locally go through this wiki page. Make sure you have installed the following:

Next follow these instructions.

  1. Database Setup: Before starting with the project create a db in you local using PostgreSQL with the following details. Refer to main/settings.py if you have any confusion.

    NAME: osp
    USER: osp
    PASSWORD: osp
    HOST: localhost
    

    You may run the following commands for local setup of DB in Linux:

    cd anitab-forms-backend
    sudo -i -u postgres
    createuser osp --pwprompt
    psql
    CREATE DATABASE osp;
    \c osp;
    GRANT ALL PRIVILEGES ON DATABASE osp to osp;
    

    You may run the following commands for local setup of DB in Windows:

    cd anitab-forms-backend
    psql -U postgres
    CREATE ROLE osp LOGIN PASSWORD 'osp' NOINHERIT CREATEDB;
    CREATE DATABASE osp;
    \c osp;
    GRANT ALL PRIVILEGES ON DATABASE osp to osp;
    
  2. Set the environment variables: You need to download Zulip API key file from your user-settings on Zulip. The file you download is named as download or rename it to download. Place that download file in the project's directory. For more information follow Environment Variables section.

  3. Move into the project's directory.

    cd anitab-forms-backend
    
  4. Create virtual environment (this is not a hard requirement, but its advisable)

    virtualenv venv
    

    Activating virtual environment for Linux users:

    source venv/bin/activate
    

    Activating virtual environment for Git Bash users:

    source ./venv/Scripts/activate
    

    Activating virtual environment for Windows users:

    venv\Scripts\activate
    
  5. To install dependencies:

    pip install -r requirements.txt
    
  6. Make sure you create .env using .env.template and update the values of corresponding environment variables or make sure you exported the following environment variables.

  7. To run the migrations run:

    python manage.py migrate
    
  8. To run the server:

    python manage.py runserver
    
  9. Navigate to http://localhost:8000/ in your browser.

  10. To change the port you may run python manage.py runserver <port_number>

  11. To run the migrations run: python manage.py migrate

  12. You can terminate the process by Ctrl+C in your terminal.

Follow the given instructions for Login into the app.

  1. You can register a new user by making a POST request on /api/token_auth/register/. After this confirmation e-mail will be sent to standard output (terminal). To receive confirmation e-mail using Sendgrid see this. The content of the request must be like this:

    {
        "username":"< YOUR USERNAME >",
        "email":"< YOUR EMAIL >",
        "password":"< YOUR PASSWORD >",
        "confirm_password":"< YOUR PASSWORD >"  
    }
  2. To create the superuser run:

    python manage.py createsuperuser
    

    Fill up the things it asked to and then Login into the app.

Environment Variables

  1. Zulip API KEY file - You can go Zulip and follow these instructions to get your API KEY. Download the file and save it in the root folder of the project with the name download.

  2. SENDGRID_API_KEY - It is optional for development. To use this variable make DEBUG=False in settings.py. Follow the given steps to create a Sendgrid API key:

    1. Go to Sendgrid's website
    2. Navigate to Settings on the left navigation bar, and then - select API Keys.
    3. Click Create API Key.
    4. Give your API key a name.
    5. Select Full Access, Restricted Access, or Billing Access. If you're selecting Restricted Access, or Billing Access, select the specific permissions to give each category. For more information, see API key permissions.
    6. Click Create & View.
    7. The API KEY is generated and displayed to you just once. So be sure to copy and save it somewhere.

Add it to your .env file as follows:

export SENDGRID_API_KEY=<your-sendgrid-api-key>
  1. SECRET_KEY - This environment variable is required for running the backend. Add SECRET_KEY in .env file or export it by using export SECRET_KEY=<YOUR SECRET KEY>.

  2. DB_BACKEND - This environment variable is used here to get the the backend class of the database. Different databases have different backends in django. You can read more about it here. Its default backend is postgresql.

  3. DB_NAME - This environment variable is required to get the name of the database. By default, its value is osp.

  4. DB_USERNAME - This environment variable is required to get the USERNAME of the user with all privileges to the above mentioned database.

  5. DB_PASSWORD - This environment variable is required to get the password of the above mentioned user i.e. the user with all the privileges to the database.

  6. DB_HOST - It is used to get the database host from the env variables. For docker it must be set to db otherwise its default value is localhost.

  7. DB_PORT - It is used to get the database port from the env variables. Different database backends have different ports. Its default value is of postgresql port i.e. 5432.

Testing

To run the tests run: python manage.py test.

QA Checks

Before creating a pull-request, always run QA checks to make your code more readable and error-free. Steps to run QA checks are:

  1. Install QA checks dependencies:
    pip install black==20.8b1
    pip install isort==5.7.0
    pip install flake8==3.8.4
    
  2. Run QA checks: ./osp-qa-checks.

Run with Docker

  1. Make sure the latest version of docker and docker-compose are installed.
  • For docker run docker -v from your terminal. If docker is not installed, install it from here.
  • For docker-compose run docker-compose -v from terminal. If it is not installed then install it by running pip install docker-compose or from here.
  1. Change Database HOST in settings.py
  • Go to main/settings.py
  • Under databases change host to db.
  1. Build docker image

Execute sudo docker-compose run web to build the image.

  1. Run docker image

Run sudo docker-compose up from the root directory of project. Navigate to http://localhost:8000 in your browser.

Note

  • Run docker-compose up --build to rebuild the image.
  • To interact with docker containers use docker exec -it {container id} bash from your terminal. Container id can be found using docker ps.

Documentation

Documentation for the project is hosted here. Docusaurus has been used for maintaining the documentation of the project.

For more information, you can read backend project wiki and the web project wiki.

Contributing

Please read the Contributing guidelines, Code of Conduct and Reporting Guidelines

Contributors

Thanks goes to these people (emoji key):


Shipra Verma

๐Ÿšง

Sankalp

๐Ÿšง

Kesha K. Kaneria

๐Ÿšง

This project follows the all-contributors specification. Contributions of any kind welcome!

Contact

You can reach the admins, maintainers and our community on AnitaB.org Open Source Zulip. If you are interested in contributing to the OSP project, you may join the stream #anitab-forms and ask questions or intereact with the community. Join Us!

License

AnitaB Forms Backend is licensed under the GNU General Public License v3.0. To know more about it you can read the LICENSE.

anitab-forms-backend's People

Contributors

17sushmita avatar aaishpra avatar aakankshaagr avatar abha224 avatar allcontributors[bot] avatar amulya-coder avatar annabauza avatar ashwinijha6 avatar bismitaguha avatar codesankalp avatar dependabot[bot] avatar devkapilbansal avatar epicadk avatar heroichitesh avatar himanshu007-creator avatar imperishablesecret avatar isabelcosta avatar jeeva2812 avatar khushishikhu avatar moazfarrukh avatar monal5031 avatar nlok5923 avatar pranjal-arora avatar rahulm2310 avatar rmpsc avatar sahil9001 avatar shriya030 avatar subhangini avatar vj-codes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

anitab-forms-backend's Issues

Bug: Link the Contributing guidelines to Readme

Describe the bug

Currently, the contributing guidelines is only mentioned in the readme but do not linked.

To Reproduce

Steps to reproduce the behavior:

  1. Go to Readme
  2. Scroll down to Contribution section
  3. See error

Expected behavior

Link the Contributing.md file in Readme so that everyone can refer.

Screenshots

image

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]

Additional context

Here is the link: https://github.com/anitab-org/open-source-programs-backend/blob/develop/.github/CONTRIBUTING.md

Final Phase

Description

As a user , I need to be able to register/login with the OSP website.

QA: Create API tests for login and register

Description

As a developer, I need to ensure the quality of my website, so that it will not crash when in use. API tests and unit tests for registration and login.

Acceptance Criteria

Update [Required]

  • Write necessary unit tests for registration
  • APIs for registration should give the correct response.
  • Write necessary unit tests for login
  • APIs for login should give the correct response.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

4 hours

As an User, I am able to edit the form responses

Description

As an User, I am able to edit the form responses

Mocks

n/a

Acceptance Criteria

Update [Required]

  • Add endpoint to edit existing form
  • Add checks for form valid or form not closed
  • Write tests
  • Link the new questions/answers correctly

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

2 days

Error in DB setup instructions in README

Describe the bug

Error in the DB setup instructions mentioned in the README.md.

To Reproduce

Steps to reproduce the behavior:

  1. While setting up with the DB instructions mentioned, errors are thrown.
  2. See error

Expected behavior

Setup instructions should work fine and smoothly

Screenshots

N/A

Desktop (please complete the following information):

All versions

Additional context

N/A

As an User, I am able to view my form submissions

Description

As an User, I am able to view my form submissions

Mocks

n/a

Acceptance Criteria

Update [Required]

  • Endpoint for listing all form feedbacks
  • Add query param for user to filter only his form submissions
  • Allow only admins and self user to access their form submissions
  • Write tests

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

Create back-end model classes for forms

Description

As a developer,I need to create model classes for forms according to the database schema, so that I can use it for retrieving data.

Mocks

db-structure-osp (2)

Update [Required]

  • create FormModel
  • create QuestionAbstractModel

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

3 hours

As an User, I am able to view the form via link.

Description

As an User, I am able to view the form via link.

Mocks

N/A

Acceptance Criteria

Update [Required]

  • Send form questions as Response
  • Add checks for users who already filled
  • Add checks for when form is closed or deleted
  • Write tests

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1.5 days

tests: Add test for views of token_auth

Is your feature request related to a problem? Please describe.

Add test code for the views in token_auth to test all the views in the token_auth app.

Describe the solution you'd like

  • Create new files with the name test_view_register.py and test_view_tokens.py inside tests\.
  • In test_view_register.py add tests for RegisterView.
  • In test_view_tokens.py add tests for TokenObtainPairView, TokenRefreshView, TokenGenerator (For details see urls.py).
    NOTE: Use Django defaults unit tests.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Additional context

Estimation

4 hours

Add test structure and some test for token_auth register serializer

Is your feature request related to a problem? Please describe.

As this repo does not contain any test, so create the test files structure so that it is modular and write some tests for token_auth.

Describe the solution you'd like

Make the structure of the test, add some test and update README.

Describe alternatives you've considered

Additional context

Add CODEOWNER file

Description

Please add a CODEOWNER file maintaining names of the maintainers/codeowners of the repo in .github folder.
This will help the users to know who are the maintainers of the repo.

Solution

mention every codeowner name using @username in CODEOWNER file.

docs: Add link in README

Is your feature request related to a problem? Please describe.

The Contributing section of the README.md doesn't have the link in the "contributing guidelines"

Describe the solution you'd like

Add the link of AnitaB.org contributing guidelines over there

Additional context

This is required for any newcomer to first read the contributing guidelines before making any contribution.

Create unit test for Create a Form API

Description

As a developer,
I need have unit tests for each functionality,
so that I can be confident when building a new feature, that there are no regression on the platform.

API: POST /api/form

The idea is to come with 3 unit tests to test this API. You may have to mock some information to properly test it.

Resources:

Acceptance Criteria

Update [Required]

  • Create 3 unit tests for POST /api/form API

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

4 hours

Bug: UserInformation has no default value in form and question views

Describe the bug

UserInformation does not have a default value, so while making a request to the form APIs, 500 internal server gets thrown.

To Reproduce

Steps to reproduce the behavior:

  1. Go to /forms in the frontend
  2. When forms exist in the backend nothing is displayed in the frontend.
  3. The network tab shows the error
  4. See error

Expected behavior

The forms should be displayed and creating forms should give a successful response.

Screenshots

N/A

Desktop (please complete the following information):

All versions

Additional context

N/A

As an Admin, I am able to create forms and add questions on backend using API

Description

As an Admin, I am able to create forms and questions using API

Mocks

N/A

Acceptance Criteria

  • Create viewsets for form feedback
  • Create serializers for form feedback
  • Crate endpoints for form feedback
  • Write tests
  • Add checks for form feedback

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

3-4 days

fix: Errors arising after addition of Zulip Stats

Describe the bug

Errors arising while saving the Zulip ID. Also migrations aren't optimized.

To Reproduce

Steps to reproduce the behavior:
Try setting up the project or pulling the recent updates
On sending user information from the frontend the error arises.

Expected behavior

The user information should get created without any error

Screenshots

Screenshot from 2020-08-31 22-15-31

Desktop (please complete the following information):

All versions

Additional context

Add any other context about the problem here.

feat: Zulip stats for the user

Description

As a User, I should be able to view my personal zulip stats on my dashboard.

Acceptance Criteria

The code handles retrieving :

  • username
  • Total messages
  • Add date of last time the stats were updated

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

doc: update ReadMe file

Description

The versions of Django and Django rest framework used for the project Open source programs(OSP) is not mentioned in the readme file and need to be added.

versions used are:
Django 3.0.7
Django rest framework 3.11.0

For additional information refer requirements.txt file.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

15 mins

Write Better Setup Instructions for setting the project.

Describe the bug

As a developer, I would need the correct setup Instructions to set up the projects locally and start working on their issues. But the current Setup instructions aren't correct as well as incomplete and are specifically targeted at users with Linux as Operating System.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://github.com/anitab-org/open-source-programs-backend
  2. Scroll down to Setup.
  3. See the Instructions.

image

There should be instructions for Windows users to set up the database

image

The cd command should be after the virtual environment commands. Also the steps are incomplete.

Expected behavior

Clear, Concise and Correct Instructions to set up the project and database for different operating Systems(preferably Windows, Linux, mac)

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Browser Firefox web Browser
  • Version --

docs: Add Setup to run in Windows

Description

As a USER for setting up this project locally in windows, I need the database and setup instructions so that I can easily run the project without facing any problem.

Mocks

image

Acceptance Criteria

Update [Required]

  • Add all the necessary instructions that are required for setting up this project in windows.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

As an Admin, I can close the form in order to stop the responses.

Description

As an Admin, I can close the form in order to stop the responses.

Mocks

N/A

Acceptance Criteria

Update [Required]

  • Set the allowed response field to False
  • Add checks to prevent any new form feedback
  • Write tests

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

Integrate Code Linters to enhance/ensure code quality

Is your feature request related to a problem? Please describe.

It is necessary for every project to follow some guidelines about how the code should be written, maintained and all. But this misses guidelines related to code quality.

Describe the solution you'd like

  • Research about some good code linters, PEP8 Formatter (As the code is written in Python)
  • Add brief description about them in Readme
  • Format the code with the linters
  • Add Github workflows to ensure the guidelines are followed by every contributor.

Describe alternatives you've considered

There are a variety of options that we can look into:-

  • Flake8 - Ensures some PEP8 guidelines and best practices
  • Pylint - Linter for Python
  • Isort - Sort the imports etc in alphabetic order
  • Black - Ensures consistency (For eg:- converting all single quotes to double quotes)

Additional context

Black formatter is included in mentorship-backend and can give an idea on how to approach the problem

Create back-end model classes for registration and login

Description

As a developer,I need to create model classes for registration and login according to the database schema, so that I can use it for retrieving data.

Mocks

db-structure-osp (2)

Update [Required]

  • create UserModel
  • create UserInformationModel

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

2 hours

docs: Add a documentation section in the README.md

Is your feature request related to a problem? Please describe.

Add a section in README.md which directs us to the wiki of the backend part of the project (open-source-programs-backend)

Describe the solution you'd like

Create a "Documentation" section with:

  • link to the wiki for further information regarding the community
  • link to open sessions which include the meeting minutes,
  • link to the video of GSoC: https://youtu.be/3A746GppZ0Y
  • link of adding a video of setting up the project: https://youtu.be/_b2RQGbYN9w
  • link of the question in zulip chats.

You can check these resources on this zulip message

Add travis CI file

Description

As a developer/QnA, I need to test the new PRs on CIs

Mocks

[INSERT RELEVANT PNG FILE]

Acceptance Criteria

Update [Required]

  • Add a travis CI file with minimal config for now

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

django project setup

Description

Setup the Django rest framework project for OSP and create the required directory structure.

Acceptance Criteria

  • create a base setup for Django project
  • add necessary dependencies
  • the server should be up and running

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

development: Create API for login

Is your feature request related to a problem? Please describe.

The registered users should be able to login with OSP to be able to use it. Create an API for user login for the OSP backend.

Describe the solution you'd like

  • If login fails - user should receive proper feedback - user/password is wrong, user not registered.
  • If login successfully - user should be directed to the main dashboard and save the access token for future login.
  • Response handling: 200 (Successful), 401 (unauthorized), 403 (forbidden), 400 (bad request), 500 (internal server error)

Additional context

NA

Bug: API response for activating users returns 403 Forbidden

Describe the bug

The backend is not able to handle the activate request and responds with:

{
    "detail": "Authentication credentials were not provided."
}

To Reproduce

Steps to reproduce the behavior:

  1. In settings.py change the email backend to console.
    EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
  2. Register a new user by making a POST request on http://127.0.0.1:8000/api/token_auth/register/ by posting the below-mentioned data.
    {
        "username":"test",
        "password":"123",
        "confirm_password":"123",
        "email":"[email protected]"
    }
    
  3. After this you will receive an email in the console which contains an activation link for the new account. This account verification link is in the format http://localhost:3000/< uidb64 >/< token >. (example: http://localhost:3000/Nw/5o6-b655d39d1a9b37aa56e2)
  4. Copy these uidb64 and token and make a get request on http://127.0.0.1:8000/api/token_auth/activate/< uidb64 >/< token >/ (For example, it will resemble like this: http://127.0.0.1:8000/api/token_auth/activate/Nw/5o6-b655d39d1a9b37aa56e2), it must return Invalid Link or email-confirmed as a response but it returns the above-mentioned error.

Expected behavior

Invalid Link or Email confirmed must be returned as a response.
This is due to the permission_classes in token_auth/views/register.py which is not able to patch permission class with custom methods like activate() which uses @api_view.

Screenshots

image

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu]
  • Browser [e.g. chrome]

How to solve?

Instead of adding the permission_classes variable use decorators separately.
Reason: permission_classes doesn't patch with activate method. I also tried with permission_classes_by_action but it is also not working.
The tested and working method is mentioned below:

from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import AllowAny

@permission_classes([AllowAny])
class RegisterView(APIView):
    
    def post(self, request, *args, **kwargs):
        pass
    
    @api_view(("GET",))
    @permission_classes([AllowAny])
    def activate(request, uidb64, token):
        pass

docs: Link to reporting guidelines incorrect in code_cf_conduct.md

Describe the bug

Link to reporting guidelines incorrect in code_cf_conduct.md

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://github.com/anitab-org/open-source-programs-backend/blob/develop/CODE_OF_CONDUCT.md#6-reporting-guidelines
  2. Click on Reporting Guidelines
  3. See error

Expected behavior

Link should be updated to https://github.com/anitab-org/open-source-programs-backend/blob/develop/REPORTING_GUIDELINES.md

Screenshots

osp-backend-coc-link

Desktop (please complete the following information):

  • OS: Any
  • Browser : Any
  • Version : Any

Additional context

Don't hardcode the links and add relative path to the file.

Create unit tests for User info API

Description

As a developer,
I need have unit tests for each functionality,
so that I can be confident when building a new feature, that there are no regression on the platform.

API: GET /api/info

The idea is to come with 3 unit tests to test this API. You may have to mock some information to properly test it.

Resources:

Acceptance Criteria

Update [Required]

  • Create 3 unit tests for GET /api/info API

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

4 hours

As an Admin, I should be able to share forms with the other users.

Description

As an Admin, I should be able to share forms with the other users.

Mocks

N/A

Acceptance Criteria

Update [Required]

  • Send form questions as Response]
  • Generate a unique link for each form
  • Automated tests for retrieval of form via unique link

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1.5 days

Database Setup

Describe the bug

Error in DB Setup

To Reproduce

Steps to reproduce the behavior:

  1. sudo -i -u postgres
  2. createuser
  3. psql
  4. CREATE DATABASE
  5. \c osp
  6. GRANT ON PRIVILEGES ON DATABASE systersdb to osp;
    ERROR: syntax error at or near "ON"
    ERROR: database "systersdb" does not exist

Expected behavior

first error it is in command GRANT ON because the command syntax it's wrong

second error
From the main/setting.py I figured the default bd is osp
so when I do command systersdb to osp I got an error as it said systersdb does not exits.

Screenshots

screen0
screen02

Desktop (please complete the following information):

All version

Additional context

N/A

Add Google OAuth register and login to OSP

Description

As a developer,
I need to implement Google sign on,
so that I can allow Google users to login using their Google account.

For being able to use the application, the user has to create a new account and confirm the email just to login. It's a long process. So by having Google OAuth we can make the process shorter for users who have a Google account.

Acceptance Criteria

Update [Required]

  • Implement Google OAuth login and registration
  • Write unit tests for the updates ^^

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

8 hours

Feature: Update the develop branch for deployment on heroku.

Is your feature request related to a problem? Please describe.

The final phase of any project is the successful deployment so that users can interact with it in production.
This website backend is currently under development but it will be beneficial for newcomers or any contributors to see the website in the production and know about this project in detail.

Describe the solution you'd like

  1. Use the develop branch as a deployment branch.
  2. Do the required changes to deploy the site on Heroku.
  3. You can see this for reference: heroku docs or this
  4. The deployment must be integrated with GitHub.
    NOTE: Allow the open-source-programs-web deployed URL to make API requests by adding the deployed URL to allowed hosts.

Additional context

Feel free to research more about this and add more features to make the deployment process easy.

Estimation

2 hours

Zulip Id Key Error from POST request on /api/info/

Describe the bug

When a new user registers from open-source-programs-frontend and tries to edit information on dashboard the Django server respond with internal server error(500).
The Error is as follows:

[27/Jan/2021 17:24:22] "POST /api/info/ HTTP/1.1" 500 18345
[27/Jan/2021 17:24:25] "GET /api/info/ HTTP/1.1" 200 2
[27/Jan/2021 17:24:25] "GET /api/user/ HTTP/1.1" 200 80
[27/Jan/2021 17:24:25] "GET /api/info/ HTTP/1.1" 200 2
[27/Jan/2021 17:24:25] "GET /api/info/ HTTP/1.1" 200 2
Internal Server Error: /api/info/
Traceback (most recent call last):
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/home/sankalp/Desktop/open-source-programs-backend/venv/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/sankalp/Desktop/open-source-programs-backend/osp/views/user_information.py", line 30, in create
    response = get_zulip_user(request.data['zulip_id'])
KeyError: 'zulip_id'

To Reproduce

Steps to reproduce the behavior:
One way:

  1. Make a POST request on http://127.0.0.1:8000/api/info/ by removing the zulip_id field as it is not a required field.
  2. Server responds with an 500 response.

Another way:

  1. Register through the frontend.
  2. Try to LOGIN using the frontend.
  3. Now try to complete fill your profile data the server responds with 500 internal server errors.

Expected behavior

See the attached screenshot.

Screenshots

image

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser: Chrome
  • Version - __

Additional context

Add any other context about the problem here.

Feat : Github stats of a user

Description

As an Admin, I should be able to view user's Github stats whose application is being reviewed.

Acceptance Criteria

The code handles retrieving:

  • username

  • Total issues created

  • Total Pull Request made till date.

  • Total commits made till date.

  • Total Pull Request Reviewed

  • Add date of last time the stats were updated

Definition of Done

  • All of the required items are completed.
  • Tests have been created to test these new features
  • Approval by 1 mentor.

Estimation

2 days

Document the env variables needed to run the backend

Description

As a developer,
I need to know which environment variables,
so that I can run the project.

There is documentation missing about the environment variables needed to have the project running.

Acceptance Criteria

Update [Required]

  • Update README with the environment variables needed to run the project and how to get them

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

0.5 hours

development: Create API for registration.

Is your feature request related to a problem? Please describe.

The new users should be able to register with OSP to be able to use it. Create an API for user registration for the OSP backend. The API would create a new user and redirect to the user dashboard.

Describe the solution you'd like

  • If registration is complete the user receives proper feedback - The user needs to confirm the email address.
  • If registration fails - the user should receive proper feedback - too short username, too weak password, etc.
  • Response handling: 201 (Successful creation), 401 (unauthorized), 403 (forbidden), 400 (bad request), 500 (internal server error)

Additional context

NA

Add GitHub Actions workflow to run tests

Description

As a developer,
I need ensure the tests are passing in the CI pipeline,
so that I can know that my code is not failing before merging.

Acceptance Criteria

Update [Required]

  • Create GitHub actions workflow to run tests

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

2 hours

Docs: Add README and Setup instructions

Is your feature request related to a problem? Please describe.

  • There is no guide for what this repository is meant for.
  • No guidelines to setup this project.

Describe the solution you'd like

  • Add an initial README.md which describes the purpose of the repository, with relevant links.
  • Add a SETUP.md with instructions to set up this project, with required libraries and packages for the purpose.

Describe alternatives you've considered

N/A

Additional context

N/A

As an User, I am able to fill the form

Description

As an User, I am able to fill the form

Mocks

n/a

Acceptance Criteria

Update [Required]

  • Create models for form feedback
  • Create viewsets for form feedback
  • Create serializers for form feedback
  • Crate endpoints for form feedback
  • Write tests
  • Add checks for form feedback

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

docs: add good badges to the readme

Is your feature request related to a problem? Please describe.

there are number of good looking badges available for the Github Readme some of are given below in the image
image

here some more badges are available . Badges
please add the badges shown in the image only and the above link is only for future reference purpose

Describe the solution you'd like

This badges can be added easily and here is the repo where you can find those in readme file don't forget to change the repository links in the badges

Additional context

This issue can be a good first timers issue and as per the context of the discussion I have opened this issue even I can work for this

Create a Docker file to run the backend

Description

As a developer,
I need a way to run the backend using Docker,
so that I can run the project with one command without the need to setup my local dev environment.

Acceptance Criteria

Update [Required]

  • Create a Dockerfile to run the project using one command
  • Add documentation on running the program using Docker on README

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 hours

Mention the correct link to open session minutes on README

Description

As a new contributor,
I need read the correct open session notes document (most current one),
so that I can be aware of most recent discussions.

The meeting minutes mentioned is the minutes from GSoC project sessions.
The new link is: https://docs.google.com/document/d/1JSyAr9bO4hJJxFvThvn_LVjW0KcEspXpzvWULRC_xJE/edit

Acceptance Criteria

Update [Required]

  • Add link to current open session minutes
  • Correct the text with link to last gsoc meeting minutes, and refer to it as the old one

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

0.5 hours

As an User, I am able to upload files to OSP

Description

As an User, I am able to upload files to OSP

Mocks

N/A

Acceptance Criteria

Update [Required]

  • Add boto to requirements
  • Write script to use boto to upload media to AWS bucket
  • Store the link of the media in models
  • Write tests

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

3-4 days

Login and password reset

Login is required after registeration of a user. Hence, adding a login view.

Password reset feature, where an email is sent on the user's email id and user can reset the password.

view all submissions and update status

Description

As an Admin, I am able to view all submissions and update status.

Acceptance Criteria

Update [Required]

  • Searching the list of forms
  • Updating the status of each form

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

1 day

doc: Move all the documentation of open-source-programs-backend to docusaurus

Is your feature request related to a problem? Please describe.

The current documentation of open-source-programs-backend needs to be moved to docusaurus.

Describe the solution you'd like

Docusaurus which will help get more focus on the content.

Describe alternatives you've considered

I've considered no alternative solutions or features.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

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.