Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Add Events Module #169

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[Draft] Add Events Module #169

wants to merge 2 commits into from

Conversation

yukitya-1811
Copy link
Contributor

Description

Add the basic model framework for the events module. This PR deals with only the backend logic for now, which includes -

  1. Models - Event, Budget, Volunteer, and Report
  2. Form for event
  3. Basic views - Dashboard, Create Event, Manage Event, Report

Fixes #167

Dependencies

List any dependencies that are required for this change.

Type of Change

What types of changes does your code introduce?
Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration. (for bug fix / breaking change)
Put an x in the boxes that apply

  • Test A
  • Test B

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Contributor

@imApoorva36 imApoorva36 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik if we use modelforms, then we need to define the fields inside the meta: using just fields= and widgets= right, and then maybe an intit for defining for example self.fields['society'].queryset = Society.objects.all()

corpus/events/forms.py Show resolved Hide resolved
corpus/events/forms.py Show resolved Hide resolved
corpus/events/forms.py Show resolved Hide resolved
Copy link
Member

@anirudhprabhakaran3 anirudhprabhakaran3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review the templates once the logic is alright.

corpus/events/forms.py Show resolved Hide resolved
corpus/events/forms.py Show resolved Hide resolved
corpus/events/forms.py Show resolved Hide resolved
'poc',
'created_at')

widgets = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to define this so explicity, right? Django does take care of showing the appropriate widget for each field.

corpus/events/models.py Show resolved Hide resolved

class Volunteer(models.Model):
event = models.ForeignKey(Event, null=False, on_delete=models.CASCADE)
exec_member = models.OneToOneField(ExecutiveMember, null=False, on_delete=models.CASCADE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One exec member can only be a volunteer once? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A ForeignKey would work better here maybe? An exec member can volunteer many times, but each volunteer instance is mapped to a single event

Comment on lines +58 to +62
event = models.OneToOneField(Event, null=False, on_delete=models.CASCADE)
item = models.CharField(null=False, max_length=255)
description = models.TextField()
cost = models.DecimalField(max_digits=12, decimal_places=2, null=False)
source = models.URLField()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies 1 event can have just one budget (which is alright)
But then that implies each event can have just one item (which is not).

Also, I don't think the budget should be in the events module. Should be part of treasury imo. cc @nishant-nayak for comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. As of now this isn't really going to be worked upon, since we're mainly focusing on just getting Events up and running

from django.contrib import messages
# Create your views here.

def dashboard(request):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decorate for permissions!

event_form.save()
messages.success(request, ("New event created!"))
else:
print(event_form.errors)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return proper errors

Comment on lines +31 to +35
def manage_event(request):
return render(request, "events/manage_event.html")

def report(request):
return render(request, "events/report.html")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing because this a draft. You'll need to fix the logic of these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Django related issues enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Events models
4 participants