Skip to content
This repository has been archived by the owner on Jan 13, 2019. It is now read-only.

Backend for OfficeHours #56

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions upe/settings.py.template

This file was deleted.

2 changes: 2 additions & 0 deletions users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ class OfficerAdmin(admin.ModelAdmin):

admin.site.register(UserProfile)
admin.site.register(OfficerProfile, OfficerAdmin)
admin.site.register(OfficeHour)
admin.site.register(BerkeleyClass)
11 changes: 5 additions & 6 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UserProfile(models.Model):
approved = models.BooleanField(default=False)
candidate_profile = models.ForeignKey('CandidateProfile', blank=True, null=True)
officer_profile = models.ForeignKey('OfficerProfile', blank=True, null=True)

gives_office_hours = models.BooleanField(default=False)

def __str__(self):
return self.user.first_name + " " + self.user.last_name
Expand Down Expand Up @@ -130,11 +130,10 @@ class OfficeHour(models.Model):

day_of_week = models.IntegerField(max_length=1, choices=DAY_OF_WEEK_CHOICES, default=1)
hour = models.IntegerField(max_length=2, choices=TIME_OF_DAY_CHOICES, default=11)
officer_username = models.CharField(max_length=30,
help_text='Please enter a valid officer username as this is used for website queries.')
user = models.ForeignKey('UserProfile', blank=True, null=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think another PR uses this, so we won't be able to actually delete it


def __str__(self):
return self.name() + " " + self.officer_username
return self.user.user.first_name + " " + self.user.user.last_name + " : " + self.name()

def name(self):
return self.day_dict[self.day_of_week] + " " + self.time_dict[self.hour]
Expand Down Expand Up @@ -213,10 +212,10 @@ class BerkeleyClass(models.Model):

class_dict = dict(CLASS_CHOICES)
class_name = models.IntegerField(max_length=5, choices=CLASS_CHOICES)
officers = models.ManyToManyField('OfficerProfile', through='OfficerClass')
user = models.ForeignKey('UserProfile', blank=True, null=True)

def __str__(self):
return self.class_dict[self.class_name]
return self.user.user.first_name + " " + self.user.user.last_name + " : " + self.name()

def name(self):
return self.class_dict[self.class_name]
Expand Down