-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ContriHUB/master
ContriHub changes
- Loading branch information
Showing
39 changed files
with
5,359 additions
and
1,828 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
env | ||
main/__pycache__ | ||
youdemy/__pycache__ | ||
db.sqlite3 | ||
db.sqlite3 | ||
static/images/Courses | ||
media/images | ||
media/image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
|
||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from .models import User, Courses, Chapters, Titles, Tag, Blogs, Comment, UserProfile, BlogLike, Project, Project_steps | ||
admin.site.register(Courses) | ||
admin.site.register(Chapters) | ||
admin.site.register(Titles) | ||
admin.site.register(Tag) | ||
admin.site.register(Blogs) | ||
admin.site.register(UserProfile) | ||
admin.site.register(BlogLike) | ||
admin.site.register(Project) | ||
admin.site.register(Project_steps) | ||
@admin.register(User) | ||
class UserAdmin(DjangoUserAdmin): | ||
|
||
fieldsets = ( | ||
(None, {'fields': ('email', 'password')}), | ||
(_('Personal info'), {'fields': ('first_name', 'last_name','role')}), | ||
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', | ||
'groups', 'user_permissions')}), | ||
(_('Important dates'), {'fields': ('last_login', 'date_joined')}), | ||
) | ||
add_fieldsets = ( | ||
(None, { | ||
'classes': ('wide',), | ||
'fields': ('email', 'password1', 'password2'), | ||
}), | ||
) | ||
list_display = ('email', 'first_name', 'last_name', 'is_staff','role') | ||
search_fields = ('email', 'first_name', 'last_name','role') | ||
ordering = ('email',) | ||
|
||
# Register your models here. | ||
@admin.register(Comment) | ||
class CommentAdmin(admin.ModelAdmin): | ||
list_display=('user', 'blog', 'timestamp') | ||
list_filter = ('timestamp',) | ||
search_fields = ('message',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.http import HttpResponse | ||
from django.shortcuts import redirect | ||
from django.http import HttpResponseForbidden | ||
from django.contrib import messages | ||
|
||
def only_mentors(view_func): | ||
def _wrapped_view(request, *args, **kwargs): | ||
user = request.user | ||
if user.is_authenticated and user.role == 'Mentor': | ||
return view_func(request, *args, **kwargs) | ||
else: | ||
messages.error(request, "You do not have access to view this page!") | ||
return _wrapped_view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
from django import forms | ||
from django.forms import modelformset_factory | ||
from main.models import Courses, Chapters, Titles, Questions, Blogs, Tag, Comment, Project, Project_steps | ||
class CourseModelForm(forms.ModelForm): | ||
class Meta: | ||
model = Courses | ||
fields = ('course_name', 'description', 'course_pictire', 'course_language') | ||
labels = { | ||
'course_name': 'Course Name', | ||
'description': 'Description', | ||
'course_pictire': 'Course Picture', | ||
'course_language': 'Course Language', | ||
} | ||
widgets = { | ||
'course_name': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Course Name here' | ||
}), | ||
'description': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Course Description here' | ||
}), | ||
'course_pictire': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'required':False, | ||
'label': 'Title Thumbnail' | ||
}), | ||
'course_language': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Course Language here' | ||
}), | ||
} | ||
ChapterFormset = modelformset_factory( | ||
Chapters, | ||
fields=('chapter_name','description','chapter_pictire' ), | ||
extra=1, | ||
widgets={ | ||
'chapter_name': forms.TextInput( | ||
attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Chapter Name here' | ||
}), | ||
'description': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Chapter Description here' | ||
}), | ||
'chapter_pictire': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'label': 'Title Thumbnail' # Add this line to set the label | ||
}), | ||
} | ||
) | ||
TitleModelFormset = modelformset_factory( | ||
Titles, | ||
fields=('title_name','description'), | ||
extra=1, | ||
widgets={'title_name': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Title Name here' | ||
}), | ||
'description': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Title Description here' | ||
}), | ||
} | ||
|
||
) | ||
|
||
QuestionModelFormset = modelformset_factory( | ||
Questions, | ||
fields=('question','answer'), | ||
extra=1, | ||
widgets={'question': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Question here' | ||
}), | ||
'answer': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Answer here' | ||
}), | ||
} | ||
) | ||
|
||
ChapterModelFormset = modelformset_factory( | ||
Chapters, | ||
fields=('chapter_name','description','chapter_pictire'), | ||
extra=1, | ||
widgets={'chapter_name': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Chapter Name here' | ||
}), | ||
'description': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Chapter Description here' | ||
}), | ||
'chapter_pictire': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'label': 'Chapter Thumbnail' # Add this line to set the label | ||
}), | ||
} | ||
|
||
) | ||
|
||
class BlogModelForm(forms.ModelForm): | ||
class Meta: | ||
model = Blogs | ||
fields = ('title', 'intro','description','conclusion', 'blog_picture') | ||
labels = { | ||
'title': 'Title', | ||
'intro':'Introduction', | ||
'description': 'Description', | ||
'conclusion': 'Conclusion', | ||
'blog_pictire': 'Blog Thumbnail', | ||
} | ||
widgets = { | ||
'title': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Title Name here' | ||
}), | ||
'intro': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Blog Introduction here' | ||
}), | ||
'description': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Blog Description here' | ||
}), | ||
'conclusion': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Blog Conclusion here' | ||
}), | ||
'blog_picture': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'required':False, | ||
'label': 'Blog Thumbnail' | ||
}), | ||
} | ||
TagFormset = modelformset_factory( | ||
Tag, | ||
fields=('name', ), | ||
extra=1, | ||
widgets={ | ||
'name': forms.TextInput( | ||
attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Tag' | ||
}), | ||
} | ||
) | ||
|
||
class CommentForm(forms.ModelForm): | ||
class Meta: | ||
model=Comment | ||
fields=('message',) | ||
#overidrinding defalut form setting and adding bootstrap | ||
def __init__(self, *args, **kwargs): | ||
super(CommentForm, self).__init__(*args, **kwargs) | ||
self.fields['message'].widget.attrs={'placeholder': 'Write your comment','class':'form-control'} | ||
|
||
|
||
class ProjectModelForm(forms.ModelForm): | ||
class Meta: | ||
model = Project | ||
fields = ('title', 'video', 'video_url', 'intro','body','picture','conclusion','code','code_language') | ||
labels = { | ||
'title': 'Project Name', | ||
'video': 'Video file', | ||
'video_url': 'Video URL', | ||
'intro': 'Introduction', | ||
'body':'Body', | ||
'picture': 'Picture', | ||
'conclusion': 'Conclusion', | ||
'code': 'Code', | ||
'code_language': 'Code Language', | ||
} | ||
widgets = { | ||
'title': forms.TextInput(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Project Name here' | ||
}), | ||
'video_url': forms.URLInput(attrs={ | ||
'class': 'form-control', | ||
'required':False, | ||
'placeholder': 'Enter Video URL here (or)' | ||
}), | ||
'video': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'required':False, | ||
'label': 'Upload Video (or)' | ||
}), | ||
'intro': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Project Introduction here' | ||
}), | ||
'body': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Project Body here' | ||
}), | ||
'picture': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'label': 'Project Thumbnail' | ||
}), | ||
'conclusion': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Project Conclusion here' | ||
}), | ||
'code': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Code here' | ||
}), | ||
'code_language': forms.Select(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter Code Language here' | ||
}), | ||
} | ||
ProjectStepFormset = modelformset_factory( | ||
Project_steps, | ||
fields=('order','text','picture' ), | ||
extra=1, | ||
widgets={ | ||
'order': forms.NumberInput(attrs={ | ||
'class': 'custom-width', | ||
'min': '1', | ||
'max': '100', | ||
'placeholder':'Enter order number here' | ||
}), | ||
|
||
'text': forms.Textarea(attrs={ | ||
'class': 'form-control', | ||
'placeholder': 'Enter your text here' | ||
}), | ||
'picture': forms.FileInput(attrs={ | ||
'class': 'form-control-file', | ||
'required':False, | ||
'label': 'Step Thumbnail', | ||
|
||
}), | ||
} | ||
) |
Empty file.
Oops, something went wrong.