Skip to content

Commit eda12f2

Browse files
committed
Minor fixes
2 parents 38b3302 + e68cc2d commit eda12f2

5 files changed

Lines changed: 29 additions & 24 deletions

File tree

notices/admin.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
from django.contrib import admin
2+
from import_export.admin import ImportExportModelAdmin
23
from notices.models import Notice, BookmarkedNotice, TrendingInCollege
34

5+
46
class BookmarkedNoticeAdmin(admin.TabularInline):
57
model = BookmarkedNotice
6-
extra=1
8+
extra = 1
79
fieldsets = (
810
(None, {
9-
'classes': ('extrapretty','wide'),
11+
'classes': ('extrapretty', 'wide'),
1012
'fields': (('user', 'notice'), 'pinned'),
1113
}),
1214
)
1315

14-
class NoticeAdmin(admin.ModelAdmin):
15-
list_display = ('faculty', 'title', 'course_branch_year', 'created', 'modified', 'visible_for_student',
16-
'visible_for_faculty', 'visible_for_hod', 'visible_for_others', 'visible_for_management'
17-
)
16+
17+
class NoticeAdmin(ImportExportModelAdmin):
18+
list_display = (
19+
'faculty', 'title', 'course_branch_year',
20+
'created', 'modified', 'visible_for_student',
21+
'visible_for_faculty', 'visible_for_hod',
22+
'visible_for_others', 'visible_for_management'
23+
)
1824
list_display_links = ('title', 'faculty')
1925
list_filter = ('faculty', 'category')
2026
list_per_page = 100
2127
inlines = [BookmarkedNoticeAdmin]
2228
fieldsets = (
2329
(None, {
2430
'classes': ('wide', 'extrapretty'),
25-
'fields': ('faculty', 'category', 'title', 'description', 'file_attached', 'course_branch_year',
26-
'visible_for_student', 'visible_for_faculty', 'visible_for_hod',
27-
'visible_for_others', 'visible_for_management', ),
31+
'fields': (
32+
'faculty', 'category', 'title', 'description',
33+
'file_attached', 'course_branch_year',
34+
'visible_for_student', 'visible_for_faculty',
35+
'visible_for_hod',
36+
'visible_for_others', 'visible_for_management', ),
2837
}),
2938
)
3039

31-
# class TrendingInCollegeAdmin(admin.ModelAdmin):
32-
# list_display = ('title', 'attachment', 'visibility')
40+
41+
class TrendingInCollegeAdmin(admin.ModelAdmin):
42+
list_display = ('title', 'attachment', 'visibility')
43+
3344

3445
admin.site.register(Notice, NoticeAdmin)
35-
# admin.site.register(TrendingInCollege, TrendingInCollegeAdmin) #Unused model
46+
admin.site.register(TrendingInCollege, TrendingInCollegeAdmin)

wifi/admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44

55
class WifiAdmin(admin.ModelAdmin):
6-
list_display = ('__unicode__', 'email', 'name', 'old_laptop_mac_address',
7-
'new_laptop_mac_address', 'branch', 'mac_registered','created', 'modified')
6+
list_display = ('__unicode__', 'email', 'name', 'old_laptop_mac_address', 'new_laptop_mac_address', 'branch', 'mac_registered', 'created', 'modified')
87
search_fields = ('old_laptop_mac_address', 'new_laptop_mac_address', 'user__username',)
98

109

wifi/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ class WifiForm(forms.ModelForm):
66

77
class Meta:
88
model = WifiDetail
9-
fields = ['old_laptop_mac_address', 'new_laptop_mac_address',]
9+
fields = ['old_laptop_mac_address', 'new_laptop_mac_address', ]
1010
exclude = ['user', ]

wifi/models.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@ class WifiDetail(models.Model):
1313
blank=False,
1414
null=False,
1515
default=None,
16-
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$',
17-
message='Enter MAC Address in Given Format.'), ])
16+
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$', message='Enter MAC Address in Given Format.'), ])
1817
new_laptop_mac_address = models.CharField(max_length=200,
1918
blank=True,
2019
null=True,
2120
default=None,
22-
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$',
23-
message='Enter MAC Address in Given Format.'), ])
21+
validators=[RegexValidator(regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$', message='Enter MAC Address in Given Format.'), ])
2422
mac_registered = models.BooleanField(default=False)
2523

26-
2724
created = models.DateTimeField("Created", null=True, auto_now_add=True)
2825
modified = models.DateTimeField("Last Modified", null=True, auto_now=True)
2926

wifi/views.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.shortcuts import render
21
from .models import WifiDetail
32
from profiles.models import StudentDetail, FacultyDetail
43
from django.contrib.auth.models import User
@@ -10,7 +9,7 @@
109
from django.utils.decorators import method_decorator
1110
from django.contrib import messages
1211
from django.http import HttpResponse
13-
from django.shortcuts import render, get_object_or_404, redirect
12+
from django.shortcuts import render
1413
from .forms import WifiForm
1514

1615
import xlsxwriter
@@ -26,8 +25,7 @@ def get(self, request):
2625
try:
2726
mac_address = WifiDetail.objects.get(user=user)
2827
if mac_address:
29-
return render(request, 'wifi/studentwifiform.html',
30-
{"user": user, "details": details, "mac_address": mac_address})
28+
return render(request, 'wifi/studentwifiform.html', {"user": user, "details": details, "mac_address": mac_address})
3129
except:
3230
return render(request, 'wifi/studentwifiform.html', {"user": user, "details": details})
3331

0 commit comments

Comments
 (0)