Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvhacks committed Sep 26, 2017
2 parents 38b3302 + e68cc2d commit eda12f2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
35 changes: 23 additions & 12 deletions notices/admin.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from notices.models import Notice, BookmarkedNotice, TrendingInCollege


class BookmarkedNoticeAdmin(admin.TabularInline):
model = BookmarkedNotice
extra=1
extra = 1
fieldsets = (
(None, {
'classes': ('extrapretty','wide'),
'classes': ('extrapretty', 'wide'),
'fields': (('user', 'notice'), 'pinned'),
}),
)

class NoticeAdmin(admin.ModelAdmin):
list_display = ('faculty', 'title', 'course_branch_year', 'created', 'modified', 'visible_for_student',
'visible_for_faculty', 'visible_for_hod', 'visible_for_others', 'visible_for_management'
)

class NoticeAdmin(ImportExportModelAdmin):
list_display = (
'faculty', 'title', 'course_branch_year',
'created', 'modified', 'visible_for_student',
'visible_for_faculty', 'visible_for_hod',
'visible_for_others', 'visible_for_management'
)
list_display_links = ('title', 'faculty')
list_filter = ('faculty', 'category')
list_per_page = 100
inlines = [BookmarkedNoticeAdmin]
fieldsets = (
(None, {
'classes': ('wide', 'extrapretty'),
'fields': ('faculty', 'category', 'title', 'description', 'file_attached', 'course_branch_year',
'visible_for_student', 'visible_for_faculty', 'visible_for_hod',
'visible_for_others', 'visible_for_management', ),
'fields': (
'faculty', 'category', 'title', 'description',
'file_attached', 'course_branch_year',
'visible_for_student', 'visible_for_faculty',
'visible_for_hod',
'visible_for_others', 'visible_for_management', ),
}),
)

# class TrendingInCollegeAdmin(admin.ModelAdmin):
# list_display = ('title', 'attachment', 'visibility')

class TrendingInCollegeAdmin(admin.ModelAdmin):
list_display = ('title', 'attachment', 'visibility')


admin.site.register(Notice, NoticeAdmin)
# admin.site.register(TrendingInCollege, TrendingInCollegeAdmin) #Unused model
admin.site.register(TrendingInCollege, TrendingInCollegeAdmin)
3 changes: 1 addition & 2 deletions wifi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@


class WifiAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'email', 'name', 'old_laptop_mac_address',
'new_laptop_mac_address', 'branch', 'mac_registered','created', 'modified')
list_display = ('__unicode__', 'email', 'name', 'old_laptop_mac_address', 'new_laptop_mac_address', 'branch', 'mac_registered', 'created', 'modified')
search_fields = ('old_laptop_mac_address', 'new_laptop_mac_address', 'user__username',)


Expand Down
2 changes: 1 addition & 1 deletion wifi/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class WifiForm(forms.ModelForm):

class Meta:
model = WifiDetail
fields = ['old_laptop_mac_address', 'new_laptop_mac_address',]
fields = ['old_laptop_mac_address', 'new_laptop_mac_address', ]
exclude = ['user', ]
7 changes: 2 additions & 5 deletions wifi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ class WifiDetail(models.Model):
blank=False,
null=False,
default=None,
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$',
message='Enter MAC Address in Given Format.'), ])
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$', message='Enter MAC Address in Given Format.'), ])
new_laptop_mac_address = models.CharField(max_length=200,
blank=True,
null=True,
default=None,
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$',
message='Enter MAC Address in Given Format.'), ])
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$', message='Enter MAC Address in Given Format.'), ])
mac_registered = models.BooleanField(default=False)


created = models.DateTimeField("Created", null=True, auto_now_add=True)
modified = models.DateTimeField("Last Modified", null=True, auto_now=True)

Expand Down
6 changes: 2 additions & 4 deletions wifi/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.shortcuts import render
from .models import WifiDetail
from profiles.models import StudentDetail, FacultyDetail
from django.contrib.auth.models import User
Expand All @@ -10,7 +9,7 @@
from django.utils.decorators import method_decorator
from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import render, get_object_or_404, redirect
from django.shortcuts import render
from .forms import WifiForm

import xlsxwriter
Expand All @@ -26,8 +25,7 @@ def get(self, request):
try:
mac_address = WifiDetail.objects.get(user=user)
if mac_address:
return render(request, 'wifi/studentwifiform.html',
{"user": user, "details": details, "mac_address": mac_address})
return render(request, 'wifi/studentwifiform.html', {"user": user, "details": details, "mac_address": mac_address})
except:
return render(request, 'wifi/studentwifiform.html', {"user": user, "details": details})

Expand Down

0 comments on commit eda12f2

Please sign in to comment.