Skip to content

Commit

Permalink
acl bugfix + fixed admin search bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdbnntt committed Feb 8, 2017
1 parent c45bfc7 commit 9956444
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
8 changes: 6 additions & 2 deletions api/models/attendee_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ def on_pre_delete(**kwargs):
@admin.register(AttendeeStatus)
class AttendeeStatusAdmin(admin.ModelAdmin):
list_filter = ('hackathon', 'rsvp_email_sent', 'rsvp_confirmed', 'checked_in')
list_display = ('id', 'user', 'created', 'comments')
list_display = ('id', 'user_info', 'created', 'comments')
list_editable = ('comments',)
list_display_links = ('id',)
search_fields = ('user', 'comments')
search_fields = ('user__email', 'user__first_name', 'user__last_name', 'comments')
ordering = ('-created',)

@staticmethod
def user_info(obj):
return "{} {} - {}".format(obj.user.first_name, obj.user.last_name, obj.user.email)
8 changes: 6 additions & 2 deletions api/models/hacker_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ def on_pre_delete(**kwargs):
@admin.register(HackerInfo)
class HackerAdmin(admin.ModelAdmin):
list_filter = ('hackathon', 'approved', 'is_first_hackathon', 'is_adult', 'school_year')
list_display = ('id', 'user', 'attendee_status', 'approved', 'school', 'school_year', 'school_major',
list_display = ('id', 'user_info', 'attendee_status', 'approved', 'school', 'school_year', 'school_major',
'is_first_hackathon', 'is_adult', 'interests', 'resume_file_name', 'created')
list_editable = ()
list_display_links = ('id',)
search_fields = ('user', 'school')
search_fields = ('user__email', 'user__first_name', 'user__last_name', 'school__name')
ordering = ('-created',)

@staticmethod
def user_info(obj):
return "{} {} - {}".format(obj.user.first_name, obj.user.last_name, obj.user.email)
7 changes: 6 additions & 1 deletion api/models/help_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ def __str__(self):
@admin.register(HelpRequest)
class HelpRequestAdmin(admin.ModelAdmin):
list_filter = ('hackathon',)
list_display = ('id', 'created', 'assigned_mentor', 'attendee_name', 'location', 'description')
list_display = ('id', 'created', 'assigned_mentor_info', 'attendee_name', 'location', 'description')
list_editable = ()
list_display_links = ('id',)
search_fields = ('attendee_name', 'location', 'description')
ordering = ('-created',)

@staticmethod
def assigned_mentor_info(obj):
return "{} {} - {}".format(obj.assigned_mentor.first_name, obj.assigned_mentor.last_name,
obj.assigned_mentor.email)
8 changes: 6 additions & 2 deletions api/models/judge_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ def on_pre_delete(**kwargs):
@admin.register(JudgeInfo)
class JudgeInfoAdmin(admin.ModelAdmin):
list_filter = ('hackathon', 'approved')
list_display = ('id', 'user', 'approved', 'affiliation', 'organizer_contact', 'created')
list_display = ('id', 'user_info', 'approved', 'affiliation', 'organizer_contact', 'created')
list_editable = ()
list_display_links = ('id',)
search_fields = ('user', 'affiliation', 'organizer_contact')
search_fields = ('user__email', 'user__first_name', 'user__last_name', 'affiliation', 'organizer_contact')
ordering = ('-created',)

@staticmethod
def user_info(obj):
return "{} {} - {}".format(obj.user.first_name, obj.user.last_name, obj.user.email)
8 changes: 6 additions & 2 deletions api/models/mentor_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ def on_pre_delete(**kwargs):
@admin.register(MentorInfo)
class MentorInfoAdmin(admin.ModelAdmin):
list_filter = ('hackathon', 'approved')
list_display = ('id', 'user', 'approved', 'affiliation', 'skills', 'motivation', 'created')
list_display = ('id', 'user_info', 'approved', 'affiliation', 'skills', 'motivation', 'created')
list_editable = ()
list_display_links = ('id',)
search_fields = ('user', 'affiliation', 'skills', 'motivation')
search_fields = ('user__email', 'user__first_name', 'user__last_name', 'affiliation', 'skills', 'motivation')
ordering = ('-created',)

@staticmethod
def user_info(obj):
return "{} {} - {}".format(obj.user.first_name, obj.user.last_name, obj.user.email)

7 changes: 5 additions & 2 deletions api/models/organizer_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ def on_pre_delete(**kwargs):
@admin.register(OrganizerInfo)
class OrganizerInfoAdmin(admin.ModelAdmin):
list_filter = ('hackathon', 'approved')
list_display = ('id', 'user', 'approved', 'teams', 'affiliation', 'motivation', 'created')
list_display = ('id', 'user_info', 'approved', 'teams', 'affiliation', 'motivation', 'created')
list_editable = ()
list_display_links = ('id',)
search_fields = ('user', 'affiliation', 'teams', 'motivation')
search_fields = ('user__email', 'user__first_name', 'user__last_name', 'affiliation', 'teams', 'motivation')
ordering = ('-created',)

@staticmethod
def user_info(obj):
return "{} {} - {}".format(obj.user.first_name, obj.user.last_name, obj.user.email)
8 changes: 6 additions & 2 deletions api/models/user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def __str__(self):
@admin.register(UserInfo)
class UserInfoAdmin(admin.ModelAdmin):
list_filter = ('shirt_size',)
list_display = ('id', 'user', 'phone_number', 'shirt_size', 'diet', 'github', 'linkedin', 'created')
list_display = ('id', 'user_info', 'phone_number', 'shirt_size', 'diet', 'github', 'linkedin', 'created')
list_editable = ()
list_display_links = ('id',)
search_fields = ('user', 'diet', 'github', 'linkedin')
search_fields = ('user__email', 'user__first_name', 'user__last_name', 'diet', 'github', 'linkedin')
ordering = ('-created',)

@staticmethod
def user_info(obj):
return "{} {} - {}".format(obj.user.first_name, obj.user.last_name, obj.user.email)
2 changes: 1 addition & 1 deletion hackfsu_com/util/acl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def remove_user_from_group(user: User, group_name: str):
validate_db_group(group_name)
matched_group = user.groups.filter(name=group_name)
if matched_group.exists():
user.groups.remove(matched_group)
user.groups.remove(matched_group[0])
user.save()


Expand Down

0 comments on commit 9956444

Please sign in to comment.