Coder Social home page Coder Social logo

events-backend's Introduction

(Cornell University Events) Backend + Website v1.0

Backend: A system that supports APIs to access data about Events and Organizations etc. on Cornell's Ithaca campus.

Website: A web app for student organizations to add events for cue. Here is a list of related repositories:

Contents

Getting Started

You will need Python 3.6 to run the latest version of this app, which uses Django 2.0.1. Django can be installed using python's inbuilt pip function.

You will need IntelliJ IDEA v2018.2.5 to run the latest version of this app, which uses the following:

  • React.js v.16.4.2
  • Material-UI v.3.0.1.

Setup

Installing requirements

If typing python gives you version 3.x):

  • pip install -r requirements.txt

Otherwise:

  • pip3 install -r requirements.txt

Copy settings from dev-settings

Linux/Mac:

  • npm run copy-settings

Windows:

  • npm run copy-settings-windows

Make migrations

If typing python gives you version 3.x):

  • python manage.py makemigrations
  • python manage.py migrate

Otherwise:

  • python3 manage.py makemigrations
  • python3 manage.py migrate

Everyday

Before you run anything, do this right after git pull:

  1. Run npm i in the project directory to install any additional front-end frameworks.

  2. Run depending on platform:

    • Linux/Mac, python 3 is default: npm run start
    • Linux/Mac, python 2 is default: npm run start3
    • Windows, python 3 is default: npm run start-windows
    • Windows, python 2 is default: npm run start3-windows

    This will copy dev_settings.py over to settings.py in events_backend, then start Webpack to hot-reload front-end changes as well as starting the Django server to hot-reload back-end changes. Isn't this an amazing script? (You can find it in package.json). Thank David later.

The front-end website will be located at 127.0.0.1:8000.

Code Review

After pushing any changes to the codebase, let's get your code reviewed. Some general guidelines:

  • Before you start changing any code, make sure you're synced with the master branch.
  • Create a new branch off master, and give it an informative name.
  • Commit your changes to this feature branch. Commit often so that you don't accidentally lose your progress!
  • Open a pull request (PR), give it a meaningful title and describe the changes that you made. Take note of any future improvements or any existing bugs with the changes you made. Give some steps as to how to test the changes you've made.
  • Notify others of the PR you created, and ask the relevant people to review it for you. They may leave comments and request changes, in which case you should make changes and push new commits to the same branch; the PR will update automatically!
  • Finally, when the change is approved by the reviewer, you can go ahead and merge the branch into the master branch.

Some things to watch out for when reviewing someone else's code:

  • Is the code documented? Are there comments that give details about what the code is doing?
  • Have commented-out lines of code been deleted?
  • Are your variable names clear, short, and meaningful?
  • Are your functions short and have a single purpose?
  • Are there redundancies in your code?

Database

If at any point, your database becomes corrupted or you no longer have db.sqlite3 in the directory:

  1. Copy settings
  2. Make migrations

Dependencies & Libraries

  • Django Rest Framework v. 3.8.2 - A Django library that provides powerful authentication protocols.
  • Django Simple History v. 2.0 - A Django library that provides methods to store changes to models, and thus, is used to create app-specific event, org. feeds.
  • react-avatar-editor - Similar to Facebook profile picture. Allows you to crop, resize, and rotate an uploaded image. Use for event image upload in event creation.

API Documentation

Contributors

2020

2018

  • Arnav Ghosh - Back-End Developer
  • Jessica Zhao - Back-End Developer
  • Jill Wu - Back-End Developer
  • Adit Gupta - Back-End Developer
  • David Chu - Front-End Developer
  • Stacy Wei - Front-End Developer

We are a part of the O-Week/Events team within Cornell Design & Tech Initiative. For more information, see our website here.

Last updated 10/21/2018.

events-backend's People

Contributors

abagh0703 avatar ag999 avatar bahartehrani avatar davidchuyaya avatar dependabot-preview[bot] avatar enochen avatar ewlsh avatar garnav avatar jboss925 avatar jess1cazhao avatar jillwuu avatar jonnachen avatar menaattia avatar ngwattcos avatar paul-kang-1 avatar rodtai avatar samchou19815 avatar shichong-97 avatar stacywei avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

events-backend's Issues

Move secrets

Secrets are present in dev_settings.py, settings_secret.py. Should move off git

Requirements: Pillow

I had issue installing Pillow 3.2.0 as part of the install script on both my Mac & Windows laptop; no errors occur when I remove the strict versioning (and install 5.3.0 instead).

Creating an Event: Location Doesn't Exist

Description
If a location does not exist, the create event form does not allow for the functionality to create a new location. Instead a user must first use /app/post/location/ to create a location and then come back to the create event form.

Remove Commented Backend Code

These code should either be revitalized or killed to avoid future confusion.

TODO List:

  • Example 1
    """
    class SignUpForm(UserCreationForm):
    name = forms.CharField(max_length=30, required=False, help_text='Optional.')
    netid = forms.CharField(max_length=30, required=False, help_text='Optional.')
    org_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
    org_email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
    facebook = forms.CharField(max_length=30, required=False, help_text='Optional.')
    website = forms.CharField(max_length=30, required=False, help_text='Optional.')
    contact_us = forms.CharField(max_length=30, required=False, help_text='Optional.')
    class Meta:
    model = User
    fields = ('org_name', 'password1', 'password2', 'name', 'netid', 'facebook', 'website', 'contact_us')
    """
  • Example 2
    # class Org(models.Model):
    # name = models.CharField(max_length=MAX_NAME_LENGTH)
    # description = models.CharField(max_length=MAX_DESC_LENGTH)
    # website = models.CharField(max_length=MAX_WEBSITE_LENGTH)
    # photo = models.ForeignKey(
    # 'Media', on_delete=models.CASCADE, blank=True, null=True)
    # contact = models.CharField(max_length=MAX_CONTACT_LENGTH)
    # verified = models.BooleanField(default=False)
    # history = HistoricalRecords()
    # owner = models.ForeignKey(
    # 'auth.User', related_name='org', on_delete=models.CASCADE) # user
    # def __str__(self):
    # return self.name

    # class Org_Media(models.Model):
    #
    # class Meta:
    # app_label = 'app'
    #
    # #org_id = models.ForeignKey('Org', on_delete=models.CASCADE, related_name = "org_media")
    # media_id = models.ForeignKey('Media',on_delete=models.CASCADE)
    # class Profile(models.Model):
    # org_name = models.CharField(max_length=30, blank=True)
    # name = models.CharField(max_length=30, blank=True)
    # netid = models.CharField(max_length=30, blank=True)
    # facebook = models.CharField(max_length=30, blank=True)
    # website = models.CharField(max_length=30, blank=True)
    # contact_us = models.BooleanField(default = False)
    # verified = models.BooleanField(default = False)
  • Example 3
    # email = serializers.SerializerMethodField()
  • Example 4
    #path('post/org/', views.OrgFormView.as_view(), name='post_org'),
    #path('post/org/<int:pk>/', views.post_detail_org, name='post_detail_org'),
    #path('post/org/<int:pk>/edit/', views.post_edit_org, name='post_edit_org'),
    #path('post/tag/', views.TagFormView.as_view(), name='post_tag'),
    #path('post/tag/<int:pk>/', views.post_detail_tag, name='post_detail_tag'),
    #path('post/event/', views.EventFormView.as_view(), name='post_event'),
    #path('post/event/<int:pk>/', views.post_detail_event, name='post_detail_event'),
    #path('post/location/', views.LocationFormView.as_view(), name='post_location'),
    #path('post/location/<int:pk>/', views.post_detail_location, name='post_detail_location'),
    #url(r'^email/orgEmail=(?P<org_email>.*)&orgName=(?P<org_name>.*)&name=(?P<name>[a-zA-Z\s]+)&netID=(?P<net_id>[a-zA-Z0-9]+)&link=(?P<link>.*)$', views.EmailDetail.as_view(), name='Email Detail'),
  • Example 5
    # def post(self, request, format=None):
    # event = Event.objects.filter(pk=request.data["event"])[0]
    # user = Token.objects.filter(
    # pk=extractToken(request.META.get("HTTP_AUTHORIZATION"))
    # )[0].user
    # attendingSet = Attendance.objects.filter(user_id=user, event_id=event)
    # if not attendingSet.exists():
    # attendance = Attendance(user_id=user, event_id=event)
    # attendance.save()
    # event.num_attendees += 1
    # event.save()
    # return HttpResponse(status=status.HTTP_200_OK)
    # # TODO: if exists then response

List of Users: /app/users/ lists superusers

Description:

  • If the admins are admin-david, admin-arnav, the API lists:
    [{"id":1,"username":"admin-david","org":[]},{"id":2,"username":"admin-arnav","org":[]}]
    which gives everyone access to information about the admins.

Suggested Remedy

  • Not list the admins that have access to the system (just regular users)

Get logged in org ID

We need some way of telling the front-end which organization is the one currently logged in, so it can make the correct API calls with its pk.

Remove Commented Frontend Code

These code should either be revitalized or killed to avoid future confusion.

TODO List:

  • Example 1
    {/* <Typography variant={"h4"} className={classes.title}>
    Account Settings
    </Typography>
    <TextField
    label="Email Address"
    className={classes.textField}
    value={this.state.email}
    onChange={e => this.setState({ email: e.target.value })}
    margin={"normal"} />
    <Typography variant={"body1"} color={"inherit"}>
    Update your email address on your
    <LinkColorless to={routes.profile.route}> profile page </LinkColorless>
  • Example 2
    {/* <Typography variant={"h4"} className={classes.title}>
    Account Settings
    </Typography>
    <TextField
    label="Email Address"
    className={classes.textField}
    value={this.state.email}
    onChange={e => this.setState({ email: e.target.value })}
    margin={"normal"} />
    <Typography variant={"body1"} color={"inherit"}>
    Update your email address on your
    <LinkColorless to={routes.profile.route}> profile page </LinkColorless>
    </Typography> */}
  • Example 3
    // import ScaleIn from 'material-ui/internal/ScaleIn';
  • Example 4
    //import VerifyCornellStatus from "./VerifyCornellStatus";
    //import VerifyOrg from "./VerifyOrg";
    //import VerifyDone from "./VerifyDone";

    //onboarding
    //describeTags: { route: "/app/describe", component: DescribeOrg }

    //verifyCornellStatus: { route: "/verifyCornellStatus/", component: VerifyCornellStatus },
    //verifyOrg: { route: "/verifyOrg", component: VerifyOrg },
    //verifyDone: { route: "/verifyDone", component: VerifyDone }
  • Example 5
    // if (tags.length > 4) {
    // this.setState({ errors: ['Only can have up to 5 tags.'] })
    // console.log("HELLO")
    // return tags
    // }

Create an Event: Shouldn't be allowed to choose a diff. organization

API - Endpoint
https://cuevents-app.herokuapp.com/app/post/event/

Description
Creating a new event allows users to choose an organization that is creating the event. In essence, this field should only list the organizations that the signed is user is the owner of, not other organizations. For example, if David owns DTI and Arnav owns CDS or Daily Sun, then when Arnav is creating an event, he should only be allowed to choose CDS or Daily Sun from the organizations. He should not be allowed to choose DTI.

Suggested Remedy
Allow a user to only select events hes the owner to on the form.

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.