diff --git a/.github/workflows/ISSUE_TEMPLATE/bug_report.md b/.github/workflows/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..f3694feb --- /dev/null +++ b/.github/workflows/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' + +--- + +**Describe the problem** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Actual behavior** +A concise description of what happens when you reproduce the behavior. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** +OS: e.g. Linux, Windows, macOS + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/ISSUE_TEMPLATE/feature_request.md b/.github/workflows/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..5307f8d0 --- /dev/null +++ b/.github/workflows/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: feature +assignees: '' + +--- + +**What problem do you want to solve? Please describe.** +A clear and concise description of what the problem is. Ex. I want to see names of unique listening ports across my organization. + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..f4c0ab35 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +# Workflow name +name: Build + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events for the "main" branch + push: + branches: ["main"] + pull_request: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v3 + - name: Install Python Dependencies + run: | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run linter on Python code files + run: | + pylint --errors-only --verbose --rcfile=pylintrc user/*.py + pylint --errors-only --verbose --rcfile=pylintrc publish/*.py + pylint --errors-only --verbose --rcfile=pylintrc search/*.py + +# - name: Run tests and coverage report +# run: | +# coverage run --source=src --data-file tests/.coverage -m pytest -s +# coverage xml --data-file tests/.coverage -o tests/coverage.xml +# coverage report --data-file tests/.coverage -m + +# - name : Send coverage report +# run: | +# pip install codacy-coverage +# export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }} +# export CODACY_API_TOKEN=${{ secrets.CODACY_API_TOKEN }} +# export CODACY_USERNAME=VSangarya +# export CODAY_PROJECT_NAME=AMATSA +# python-codacy-coverage -r tests/coverage.xml diff --git a/.github/workflows/pull_request_template.md b/.github/workflows/pull_request_template.md new file mode 100644 index 00000000..b5d47d74 --- /dev/null +++ b/.github/workflows/pull_request_template.md @@ -0,0 +1,3 @@ +# PR template +* Give a concise summary and a short description of what changed in files that have beed added/modified. +* Link related issues to PR. diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index 3e093205..00000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Pylint - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10"] - steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pylint - - - name: Analysing the code with pylint - uses: cclauss/Find-Python-syntax-errors-action@master diff --git a/.github/workflows/python_style_checker.yml b/.github/workflows/python_style_checker.yml deleted file mode 100644 index a6dc3807..00000000 --- a/.github/workflows/python_style_checker.yml +++ /dev/null @@ -1,7 +0,0 @@ -on: push -name: Python Style Checker -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: andymckay/pycodestyle-action@0.1.3 diff --git a/.github/workflows/python_syntax_check.yml b/.github/workflows/python_syntax_check.yml deleted file mode 100644 index 32d038af..00000000 --- a/.github/workflows/python_syntax_check.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: lint_python -on: [pull_request, push] -jobs: - lint_python: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety - - run: bandit --recursive --skip B101 . || true # B101 is assert statements - - run: black --check . || true - - run: codespell || true # --ignore-words-list="" --skip="" - - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --show-source --statistics - - run: isort --check-only --profile black . || true - - run: pip install -r requirements.txt || true - - run: mypy --install-types --non-interactive . || true - - run: pytest . || true - - run: pytest --doctest-modules . || true - - run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true - - run: safety check - diff --git a/.github/workflows/testcases.yml b/.github/workflows/testcases.yml deleted file mode 100644 index 5ebd8afd..00000000 --- a/.github/workflows/testcases.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: run test cases -on: [pull_request, push] -jobs: - test_python: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 - - uses: actions/checkout@v3 - - run: pip install -r requirements.txt || true - - run: python manage.py test - - run: pip install coverage - - run: coverage run ./manage.py test - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 diff --git a/.gitignore b/.gitignore index f799b197..73d14ad7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ +# config files +config.yml + # Byte-compiled / optimized / DLL files __pycache__/ -config.ini PackTravel/__pycache__/ *.py[cod] *$py.class diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..bbffb348 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "editor.insertSpaces": true, + "editor.tabSize": 4, + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.linting.pylintArgs": [ + "--rcfile", + "${workspaceFolder}/pylintrc" + ] +} \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE-OF-CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to CODE-OF-CONDUCT.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3098f26c..919ed52b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,7 @@ The following is a set of guidelines for contributing to PackTravel. [How Can I Contribute?](#how-can-i-contribute) * [Reporting Bugs](#reporting-bugs) * [Suggesting Enhancements](#suggesting-enhancements) + * [Style Guides](#style-guides) * [Pull Requests](#pull-requests) @@ -55,6 +56,8 @@ This section guides you through submitting an enhancement suggestion, including * **Drop an [email](mailto:help@packtravel.io) suggesting your change and start writing code.** * **Do not open an issue on GitHub until you have collected positive feedback about the change. GitHub issues are primarily intended for bug reports and fixes.** +### Style Guides +This project uses Python linter to ensure the code style is uniform and conforms to a well known syntactical style: [Pylint analyser](https://pylint.pycqa.org/en/latest/). ### Pull Requests diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 00000000..6d3c45c7 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,26 @@ +# 👩🏼‍💻 🚀 Developer Environment Setup +## Prerequisites +1. Python 3.6+ +2. VS Code (to make collaboration easier. We don't want to argue over tabs vs spaces!) +3. MongoDB Cloud Account: After setting up your free account on [MongoDB](https://www.mongodb.com/cloud/atlas/register) cloud, you will have a username, password and the database connection string. +## Setup +1. Clone this repository to your local machine. + +2. Change terminal to repository directory and create a new virtual environment using venv: `path/to/python -m venv .venv` + +3. Activate virtual environment:
+Linux/MacOS: `source .venv/bin/activate`
+Windows: `.venv/Scripts/activate`
+ +4. Install Python dependencies +```Text +pip install -r requirements.txt +``` + +5. Add your MongoDB connection string and user credentials to the `config.yml` file in the repository root directory. + +6. Start the development server using the following commands +```Text +python manage.py migrate +python manage.py runserver +``` diff --git a/LICENSE b/LICENSE index 90faebad..41c7ad44 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Amisha Waghela +Copyright (c) 2022 VSangarya Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/PackTravel/urls.py b/PackTravel/urls.py index 8f1affbc..371fd802 100644 --- a/PackTravel/urls.py +++ b/PackTravel/urls.py @@ -31,5 +31,7 @@ path('create_ride/', publishViews.create_ride, name='create_ride'), path('add_route/', publishViews.add_route, name='add_route'), path('select_route/', publishViews.select_route, name='select_route'), - path('display_ride/', publishViews.display_ride, name='display_ride') + path('display_ride/', publishViews.display_ride, name='display_ride'), + path('route_page/',publishViews.show_route,name="showroutepage"), + path('add_forum/',publishViews.add_forum,name="addforum") ] diff --git a/README.md b/README.md index 8ea7b86a..7d6ad59c 100644 --- a/README.md +++ b/README.md @@ -1,181 +1,34 @@ -
- - -# `PackTravel` - - - - - -[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7178601.svg)](https://doi.org/10.5281/zenodo.7178601) -[![codecov](https://codecov.io/gh/amisha-w/PackTravel/branch/main/graph/badge.svg?token=HRFN97UEB7)](https://codecov.io/gh/amisha-w/PackTravel) -![Python Style Checker](https://github.com/amisha-w/PackTravel/actions/workflows/python_style_checker.yml/badge.svg) -![Lint Python](https://github.com/amisha-w/PackTravel/actions/workflows/pylint.yml/badge.svg) - -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT) -[![contributors](https://img.shields.io/github/contributors/amisha-w/PackTravel?style=for-the-badge)](https://github.com/amisha-w/PackTravel/graphs/contributors) -[![Total Lines](https://img.shields.io/tokei/lines/github/amisha-w/PackTravel?style=for-the-badge)](https://img.shields.io/tokei/lines/github/amisha-w/PackTravel) -[![Issues](https://img.shields.io/github/issues/amisha-w/PackTravel?style=for-the-badge)](https://github.com/amisha-w/PackTravel/issues) -[![Closed Issues](https://img.shields.io/github/issues-closed-raw/amisha-w/PackTravel?style=for-the-badge)](https://github.com/amisha-w/PackTravel/issues?q=is%3Aissue+is%3Aclosed) -[![Pull Requests](https://img.shields.io/github/issues-pr/amisha-w/PackTravel?style=for-the-badge)](https://github.com/amisha-w/PackTravel/pulls) -[![Commit Acitivity](https://img.shields.io/github/commit-activity/w/amisha-w/PackTravel?style=for-the-badge)](https://github.com/amisha-w/PackTravel/graphs/commit-activity) -[![Repo Size](https://img.shields.io/github/repo-size/amisha-w/PackTravel?style=for-the-badge)](https://github.com/amisha-w/PackTravel) - - -
-

🏆 Goal

- -_Travelling alone?_ **Try PackTravel** - - -**Project Description:** - -Most of the university students do not have a car to travel off-campus and rely mostly on the Wolfline. But what if someone wants to travel outside Wolfline's limit? Well... why not collaborate on PackTravel to travel off-campus by a cab, rental car, etc. - - - - - -**So, let's PackTravel 😎** - -

Features

- -
    -
  • Create a PackTravel Ride
  • -
  • Create mmultiple routes to reach a ride's destination: Bus, Cab or Personal
  • -
  • Search and view other's rides
  • -
  • Join a PackTravel Ride's route
  • - -
- -## 🚀 A bit abut PackTravel +# 🐺 PackTravel +[![Build](https://github.com/VSangarya/PackTravel/actions/workflows/build.yml/badge.svg)](https://github.com/VSangarya/PackTravel/actions/workflows/build.yml) +[![Commit Acitivity](https://img.shields.io/github/commit-activity/w/VSangarya/PackTravel)](https://github.com/VSangarya/PackTravel/pulse) +[![Issues](https://img.shields.io/github/issues/VSangarya/PackTravel?color=red)](https://github.com/VSangarya/PackTravel/issues) +[![Contributors](https://img.shields.io/github/contributors/VSangarya/PackTravel)](https://github.com/VSangarya/PackTravel/graphs/contributors) +[![License](https://img.shields.io/github/license/VSangarya/PackTravel)](LICENSE) +![Languages](https://img.shields.io/github/languages/count/VSangarya/PackTravel) +[![Code Size](https://img.shields.io/github/languages/code-size/VSangarya/PackTravel)](https://github.com/VSangarya/PackTravel/) +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE-OF-CONDUCT.md) +[![Repo Size](https://img.shields.io/github/repo-size/VSangarya/PackTravel)](https://github.com/VSangarya/PackTravel/) + +_Travelling alone?_ **Let's PackTravel!** + +Most university students do not have a car and rely on Wolfline. But what if you want to travel outside Wolfline's limit? Well...why not collaborate on PackTravel to travel off-campus by a cab, rental car, etc. + +## 💎 Features +* Create a ride +* Create multiple routes to any destination: Bus, Cab or Personal +* Search and view rides posted by other users +* Join rides https://user-images.githubusercontent.com/111834635/194171771-962a585e-5dc7-4ea3-af35-732ebd34e76c.mp4 -**Built Using:** -
- - - - - - - - - - - -## 📖 Getting started: - -### 👤 Who can use our app - - 1. If you are a user who is visiting our app, you can sign up as a user with view access to rides. You can edit or create your own ride. - 2. If you are an admin user, you can create, view, update and delete rides and schedule rides. - 3. To request for admin privileges, please email on help@packtravel.io with the purpose of use. - - - ### Prerequisite: - - Download [Python3.x](https://www.python.org/downloads/). - - Download [Django](https://docs.djangoproject.com/en/4.1/topics/install/). - - ## Run Locally - -Create a virtual environment: - -```bash - python3.x -m venv test_env -``` - -Activate the virtual environment: -Linux/MacOS: -```bash - source test_env/bin/activate -``` -Windows: -```bash - ./test_env/Scripts/activate -``` - -Clone the project - -```bash - git clone https://github.com/amisha-w/PackTravel.git -``` - -Go to the project directory - -```bash - cd PackTravel -``` - -Install dependencies - -```bash - pip install -r requirements.txt -``` - -Start the server - -```bash - python manage.py migrate - python manage.py runserver -``` - - - - - Site will be hosted at: - `http://127.0.0.1:5000/` - -## 🛠️ Tools -- [Preetier Code Formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) -- [JS-HTML-CSS Formatter](https://marketplace.visualstudio.com/items?itemName=lonefy.vscode-JS-CSS-HTML-formatter) -- [PyLint](https://pylint.org/) - -## 🧑‍💻 Functionalities in Action - -- **Login Page** -![](https://github.com/amisha-w/PackTravel/blob/main/images/Login%20(1).gif) - -- **Creating a Ride** -![](https://github.com/amisha-w/PackTravel/blob/main/images/Create1.gif) -![](https://github.com/amisha-w/PackTravel/blob/main/images/Create2.gif) - -- **Search for a Ride** -![](https://github.com/amisha-w/PackTravel/blob/main/images/Search.gif) - -- **Joining an existing Ride** -![](https://github.com/amisha-w/PackTravel/blob/main/images/JoinRide.gif) - -- **Adding New Route** -![](https://github.com/amisha-w/PackTravel/blob/main/images/AddRoute11.gif) -![](https://github.com/amisha-w/PackTravel/blob/main/images/AddRoute12.gif) - -- **Sign Up Page** -![](https://github.com/amisha-w/PackTravel/blob/main/images/Register.gif) - - - - -## 💬 Chat Channel - - - - -### 🎯 Phase 1: - -- [x] Create database ER diagram -- [x] Create Mongo Database -- [x] Create HomePage -- [x] Create Login and Signup Page -- [x] Create Search Page -- [x] Added create Rides Page -- [x] Added create routes Page -- [x] Setup Django -- [x] Add Unit testing -- [x] Add Error Handling mechanisms -- [x] Setup Workflows - -### 🎯 Future Enhancements: +## 📖 Usecases +* Users: Create new rides, view and join available rides. +* Administrators: User permissions + update, delete or schedule rides. To request administrator access, please email on help@packtravel.io with the purpose of use. +## ⚒️ Installation +* See [developer environment setup](INSTALL.md#--developer-environment-setup) to setup your development server. + +## 🎯 Enhancements - [ ] Add machine learning algorithms for predicting lowest priced rides, best pickup and drop-off locations. - [ ] Add functionality to merge routes - [ ] Show later departures in search if currently searched rides is not available @@ -184,23 +37,10 @@ Start the server - [ ] Integrate in-app cab booking services - [ ] Introduce a two way ride confirmation feature -## Contributions to the Project - -## 👨‍🏭 Contributors - - - - - - - - - -

Amisha Waghela

Aoishi Das


Ameya Chavan


Kunal Shah


Swarnamalya M

- - -

❗ TroubleShooting and Help Guide

- - 1. For any issues faced while using the application, please email the detailed description and steps to reproduce the error at help@packtravel.io . - 2. If you are a developer, please raise an issue on github with steps to reproduce and possible source of error. - 3. Our email is monitored 24x7 and we usually respond within 1 hour. Happy Emailing :). +## 📨 Help and Troubleshooting +For any help or assistance regarding the software, please e-mail any of the developers with the query or a detailed description. Additionally, please use issues on GitHub for any software related issues, bugs or questions. +* mquresh@ncsu.edu +* apandit3@ncsu.edu +* vnagara3@ncsu.edu +* schopra4@ncsu.edu +* lsangar@ncsu.edu diff --git a/codecov b/codecov deleted file mode 100644 index c9b68ca3..00000000 Binary files a/codecov and /dev/null differ diff --git a/config.yml b/config.yml new file mode 100644 index 00000000..8ee0251a --- /dev/null +++ b/config.yml @@ -0,0 +1,4 @@ +database: + endpoint: packtravel.cyumok3.mongodb.net/?retryWrites=true&w=majority + username: database + password: givemewriteaccess diff --git a/db.sqlite3 b/db.sqlite3 index 950f319d..f4425908 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/publish/views.py b/publish/views.py index 2a1f72e8..e2e4c77e 100644 --- a/publish/views.py +++ b/publish/views.py @@ -6,6 +6,7 @@ from django.contrib.auth import login, authenticate from django.contrib import messages from django.contrib.auth.forms import UserCreationForm +from datetime import datetime from publish.forms import RideForm from utils import get_client @@ -191,4 +192,31 @@ def attachUserToRoute(username, route_id, ride_id): users.append(username) routesDB.update_one({"_id": route_id}, {"$set": {"users": users}}) - +def show_route(request,route_id): + intializeDB() + # if request.method=="POST": + # username=request.session['username'] + # date=datetime.now() + # content=request.POST['content'] + # post={"user":username,"date":date,"content":content} + # routesDB.update_one({"_id": route_id}, {"$push": {"forum": post}}) + + route = routesDB.find_one({'_id': route_id}) + if 'forum' not in route: + forum=[] + else: + forum=route['forum'] + name=route['type'] + spoint=route['spoint'] + #Add the destination once we remove dependency between route and rides + return render(request,'publish/show_route.html',{'route_name':name,'forum':forum,'spoint':spoint,'route_id':route_id}) +def add_forum(request): + if request.method=='POST': + intializeDB() + username=request.session['username'] + date=datetime.now() + content=request.POST['content'] + route_id=request.POST['route'] + post={"user":username,"date":date,"content":content} + routesDB.update_one({"_id": route_id}, {"$push": {"forum": post}}) + return redirect(show_route,route_id=route_id) \ No newline at end of file diff --git a/pylintrc b/pylintrc new file mode 100644 index 00000000..b548b519 --- /dev/null +++ b/pylintrc @@ -0,0 +1,428 @@ +# This Pylint rcfile contains a best-effort configuration to uphold the +# best-practices and style described in the Google Python style guide: +# https://google.github.io/styleguide/pyguide.html +# +# Its canonical open-source location is: +# https://google.github.io/styleguide/pylintrc + +[MASTER] + +# Files or directories to be skipped. They should be base names, not paths. +ignore=third_party + +# Files or directories matching the regex patterns are skipped. The regex +# matches against base names, not paths. +ignore-patterns= + +# Pickle collected data for later comparisons. +persistent=no + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Use multiple processes to speed up Pylint. +jobs=4 + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +#enable= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once).You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use"--disable=all --enable=classes +# --disable=W" +disable=abstract-method, + apply-builtin, + arguments-differ, + attribute-defined-outside-init, + backtick, + bad-option-value, + basestring-builtin, + buffer-builtin, + c-extension-no-member, + consider-using-enumerate, + cmp-builtin, + cmp-method, + coerce-builtin, + coerce-method, + delslice-method, + div-method, + duplicate-code, + eq-without-hash, + execfile-builtin, + file-builtin, + filter-builtin-not-iterating, + fixme, + getslice-method, + global-statement, + hex-method, + idiv-method, + implicit-str-concat, + import-error, + import-self, + import-star-module-level, + inconsistent-return-statements, + input-builtin, + intern-builtin, + invalid-str-codec, + locally-disabled, + long-builtin, + long-suffix, + map-builtin-not-iterating, + misplaced-comparison-constant, + missing-function-docstring, + metaclass-assignment, + next-method-called, + next-method-defined, + no-absolute-import, + no-else-break, + no-else-continue, + no-else-raise, + no-else-return, + no-init, # added + no-member, + no-name-in-module, + no-self-use, + nonzero-method, + oct-method, + old-division, + old-ne-operator, + old-octal-literal, + old-raise-syntax, + parameter-unpacking, + print-statement, + raising-string, + range-builtin-not-iterating, + raw_input-builtin, + rdiv-method, + reduce-builtin, + relative-import, + reload-builtin, + round-builtin, + setslice-method, + signature-differs, + standarderror-builtin, + suppressed-message, + sys-max-int, + too-few-public-methods, + too-many-ancestors, + too-many-arguments, + too-many-boolean-expressions, + too-many-branches, + too-many-instance-attributes, + too-many-locals, + too-many-nested-blocks, + too-many-public-methods, + too-many-return-statements, + too-many-statements, + trailing-newlines, + unichr-builtin, + unicode-builtin, + unnecessary-pass, + unpacking-in-except, + useless-else-on-loop, + useless-object-inheritance, + useless-suppression, + using-cmp-argument, + wrong-import-order, + xrange-builtin, + zip-builtin-not-iterating, + + +[REPORTS] + +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html. You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages +reports=no + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details +#msg-template= + + +[BASIC] + +# Good variable names which should always be accepted, separated by a comma +good-names=main,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Include a hint for the correct naming format with invalid-name +include-naming-hint=no + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +property-classes=abc.abstractproperty,cached_property.cached_property,cached_property.threaded_cached_property,cached_property.cached_property_with_ttl,cached_property.threaded_cached_property_with_ttl + +# Regular expression matching correct function names +function-rgx=^(?:(?PsetUp|tearDown|setUpModule|tearDownModule)|(?P_?[A-Z][a-zA-Z0-9]*)|(?P_?[a-z][a-z0-9_]*))$ + +# Regular expression matching correct variable names +variable-rgx=^[a-z][a-z0-9_]*$ + +# Regular expression matching correct constant names +const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ + +# Regular expression matching correct attribute names +attr-rgx=^_{0,2}[a-z][a-z0-9_]*$ + +# Regular expression matching correct argument names +argument-rgx=^[a-z][a-z0-9_]*$ + +# Regular expression matching correct class attribute names +class-attribute-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$ + +# Regular expression matching correct inline iteration names +inlinevar-rgx=^[a-z][a-z0-9_]*$ + +# Regular expression matching correct class names +class-rgx=^_?[A-Z][a-zA-Z0-9]*$ + +# Regular expression matching correct module names +module-rgx=^(_?[a-z][a-z0-9_]*|__init__)$ + +# Regular expression matching correct method names +method-rgx=(?x)^(?:(?P_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P_{0,2}[a-z][a-z0-9_]*))$ + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=(__.*__|main|test.*|.*test|.*Test)$ + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=10 + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager,contextlib2.contextmanager + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=140 + +# TODO(https://github.com/PyCQA/pylint/issues/3352): Direct pylint to exempt +# lines made too long by directives to pytype. + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=(?x)( + ^\s*(\#\ )??$| + ^\s*(from\s+\S+\s+)?import\s+.+$) + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=yes + +# Maximum number of lines in a module +max-module-lines=99999 + +# String used as indentation unit. The internal Google style guide mandates 2 +# spaces. Google's externaly-published style guide says 4, consistent with +# PEP 8. +indent-string=' ' + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=TODO + + +[STRING] + +# This flag controls whether inconsistent-quotes generates a warning when the +# character used as a quote delimiter is used inconsistently within a module. +check-quote-consistency=yes + + +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=^\*{0,2}(_$|unused_|dummy_) + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_,_cb + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six,six.moves,past.builtins,future.builtins,functools + + +[LOGGING] + +# Logging modules to check that the string format arguments are in logging +# function parameter format +logging-modules=logging,absl.logging,tensorflow.io.logging + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + + +[SPELLING] + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub, + TERMIOS, + Bastion, + rexec, + sets + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant, absl + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls, + class_ + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=StandardError, + Exception, + BaseException diff --git a/requirements.txt b/requirements.txt index e1cd2ae9..f56011fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,12 @@ asgiref==3.5.2 +astroid==2.12.13 async-generator==1.10 attrs==22.1.0 certifi==2021.10.8 charset-normalizer==2.1.1 chromedriver-autoinstaller==0.4.0 cycler==0.11.0 +dill==0.3.6 Django==4.1.2 dnspython==2.2.1 exceptiongroup==1.0.0rc9 @@ -12,21 +14,27 @@ fonttools==4.25.0 h11==0.14.0 idna==3.4 iniconfig==1.1.1 +isort==5.10.1 kiwisolver==1.4.4 +lazy-object-proxy==1.8.0 matplotlib==3.5.3 +mccabe==0.7.0 numpy==1.23.2 outcome==1.2.0 packaging==21.3 pandas==1.4.4 Pillow==9.0.1 +platformdirs==2.5.4 pluggy==1.0.0 py==1.11.0 +pylint==2.15.6 pymongo==4.2.0 pyparsing==3.0.9 PySocks==1.7.1 pytest==7.1.1 python-dateutil==2.8.2 pytz==2021.3 +PyYAML==6.0 requests==2.28.1 scipy==1.9.1 selenium==4.5.0 @@ -35,7 +43,9 @@ sniffio==1.3.0 sortedcontainers==2.4.0 sqlparse==0.4.3 tomli==2.0.1 +tomlkit==0.11.6 trio==0.22.0 trio-websocket==0.9.2 urllib3==1.26.12 +wrapt==1.14.1 wsproto==1.2.0 diff --git a/templates/publish/route.html b/templates/publish/route.html index 29de8d07..461df156 100644 --- a/templates/publish/route.html +++ b/templates/publish/route.html @@ -103,18 +103,19 @@
Routes:
+ {% if ride.type == "Bus" %} {% elif ride.type == "Cab" %} {% endif %} - {{ route.type }} + {{ route.type }} {{ route.hour }}:{{ route.minute }} {{ route.ampm }} {{ route.duration }} minutes {{ route.users|length }} {{ route.details }} - + diff --git a/user/forms.py b/user/forms.py index e04bb420..3b7ddfed 100644 --- a/user/forms.py +++ b/user/forms.py @@ -9,7 +9,7 @@ class RegisterForm(forms.ModelForm): first_name = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder': 'First Name', 'class': 'form-control'})) last_name = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder': 'Last Name', 'class': 'form-control'})) email = forms.EmailField(required=True, max_length=60, widget=forms.EmailInput(attrs={'placeholder': 'abc@mail.com', 'class': 'form-control'})) - password1 = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder': 'Password','class': "form-control"})) + password1 = forms.CharField(required=True, widget=forms.PasswordInput(attrs={'placeholder': 'Password','class': "form-control"})) phone_number = forms.CharField(required=True, max_length=11, widget=forms.TextInput(attrs={'placeholder': 'Phone Number', 'class': 'form-control'})) class Meta: @@ -26,7 +26,7 @@ class Meta: class LoginForm(forms.ModelForm): username = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder': 'Enter your username', 'class': "form-control"})) - password = forms.CharField(required=True, widget=forms.TextInput(attrs={'placeholder': 'Password', 'class': "form-control"})) + password = forms.CharField(required=True, widget=forms.PasswordInput(attrs={'placeholder': 'Password', 'class': "form-control"})) class Meta: model = User fields = ('username', 'password') diff --git a/user/views.py b/user/views.py index c6651fba..a4e8ac7d 100644 --- a/user/views.py +++ b/user/views.py @@ -3,11 +3,12 @@ import requests import json from django.http import HttpResponse -from django.contrib.auth import login, authenticate +from django.contrib.auth import authenticate from django.contrib import messages from django.contrib.auth.forms import UserCreationForm from utils import get_client from .forms import RegisterForm, LoginForm +import hashlib @@ -38,13 +39,19 @@ def register(request): if request.method == "POST": form = RegisterForm(request.POST) if form.is_valid(): + password=form.cleaned_data["password1"] + username=form.cleaned_data["username"] + user = userDB.find_one({"username": username}) + # print(user) + if user: + return render(request, 'user/register.html', {"form": form,"alert":'Username already exists'}) userObj = { - "username": form.cleaned_data["username"], + "username": username, "unityid": form.cleaned_data["unityid"], "fname": form.cleaned_data["first_name"], "lname": form.cleaned_data["last_name"], "email": form.cleaned_data["email"], - "password": form.cleaned_data["password1"], + "password": hashlib.sha256(password.encode()).hexdigest(), "phone": form.cleaned_data["phone_number"], "rides": [] } @@ -62,7 +69,7 @@ def register(request): if request.session.has_key('username'): return index(request,request.session['username']) form = RegisterForm() - return render(request, 'user/register.html', {"form": form}) + return render(request, 'user/register.html', {"form": form,"alert":''}) def logout(request): try: @@ -85,7 +92,7 @@ def login(request): passw = form.cleaned_data["password"] user = userDB.find_one({"username": username}) - if user and user["password"] == form.cleaned_data["password"]: + if user and user["password"] == hashlib.sha256(form.cleaned_data["password"].encode()).hexdigest(): request.session["username"] = username request.session['unityid'] = user["unityid"] request.session['fname'] = user["fname"] diff --git a/utils.py b/utils.py index 6bb0f5c4..bc89e409 100644 --- a/utils.py +++ b/utils.py @@ -1,12 +1,13 @@ +"""File containing helper method to load configuration""" + import os -import sys +import yaml from pymongo import MongoClient - def get_client(): - with open(os.path.join(sys.path[0], "config.ini"), "r") as f: - content=f.readlines() - client = MongoClient("mongodb+srv://Aoishi:"+content[0]+"@cluster0.zpuftvw.mongodb.net/?retryWrites=true&w=majority") - - + # read config from yml file + with open(os.path.dirname(os.path.realpath(__file__)) + "/config.yml", "r", encoding="utf-8") as file: + config = yaml.safe_load(file) + endpoint = "mongodb+srv://" + config["database"]["username"] + ":" + config["database"]["password"] + "@" + config["database"]["endpoint"] + client = MongoClient(endpoint) return client