Esempio n. 1
0
def new(request):
	if request.user.is_authenticated():
		if request.POST:
			subj = request.POST['subject']
			details = request.POST['details']
			a = Announcement(subject=subj, content=details)
			a.save()
		return announceView(request)
	return HttpResponseRedirect('/login/')	
Esempio n. 2
0
def set_announcements(announcements):
    try:
        for a in announcements:
            #print(a)
            A = Announcement(text = a)
            A.save()
    except Exception as e:
        #print(e)
        return False
    return True
Esempio n. 3
0
def announce(request, pk):
    club = Club.objects.get(pk=pk)
    if request.POST:
        announce = Announcement(club=club)
        form = AnnouncementForm(request.POST,instance=announce )
        if form.is_valid():
            announce = form.save()
            announce.save()
            return render_to_response('announcement/successful_post.html', context_instance = RequestContext(request))
    else:
        form = AnnouncementForm()
            
    return render_to_response('club/make_announcement.html', {'form':form}, context_instance = RequestContext(request) )
Esempio n. 4
0
def index(request):
    """ Index page of the Website.

    """
    latest_news = News.get_latest_news(3)
    latest_announcement = Announcement.get_latest_announcements(5)
    events_list = Event.get_latest_events(3)
    active_images = carousel_api.get_all_index_page_images()
    imp_news_announcement = sorted(chain(
        News.get_news_tag('important'),
        Announcement.get_announcement_tag('important')),
                                   key=attrgetter('start_date'))
    context = {
        'latest_news': latest_news,
        'latest_announcement': latest_announcement,
        'events': events_list,
        'carousel': active_images,
        'imp_news_announcement': imp_news_announcement,
    }
    return render(request, 'basic/index.html', context)
Esempio n. 5
0
def simple_tag(request, tag_name):
    """ View for simple tag listing """
    latest_announcement = Announcement.get_latest_announcement_tag(tag_name, 5)
    latest_news = News.get_latest_news_tag(tag_name, 5)
    latest_images = PhotoExtended.get_latest_images_tag(tag_name, 5)
    args = {
        'latest_announcement': latest_announcement,
        'latest_news': latest_news,
        'latest_images': latest_images,
    }
    return render(request, 'tag/simple_tag.html', args)
Esempio n. 6
0
def announcement_tag(request, tag_name):
    """ View for announcement tag listing """
    announcements = Announcement.get_announcement_tag(tag_name)
    announcements, num_items, page = utils.paginate_view(
        request, announcements)
    args = {
        'announcements': announcements,
        'num_items': num_items,
        'curr_page': page
    }
    return render(request, 'tag/announcement_tag.html', args)
Esempio n. 7
0
def add_announcement(request):
    if request.method == 'POST':
        form = AnnouncementForm(request.POST, request.FILES)
        if form.is_valid():
            current_user = request.user
            data = Announcement()
            data.user_id = current_user.id
            data.announcements_id = id
            data.title = form.cleaned_data['title']
            data.keywords = form.cleaned_data['keywords']
            data.description = form.cleaned_data['description']
            data.image = form.cleaned_data['image']
            data.category = form.cleaned_data['category']
            data.slug = form.cleaned_data['slug']
            data.detail = form.cleaned_data['detail']
            data.status = 'False'
            data.save()
            messages.success(request, 'Your Content Recorded Successfully ')
            return HttpResponseRedirect('/user/announcements')
        else:
            messages.error(request,
                           'Announcement Form Error :' + str(form.errors))
            return HttpResponseRedirect('/user/addannouncement')
    else:
        setting = Setting.objects.get(pk=2)
        category = Category.objects.all()
        form = AnnouncementForm()
        menu = Menu.objects.all()
        context = {
            'category': category,
            'form': form,
            'menu': menu,
            'setting': setting
        }
        return render(request, 'user_addannouncement.html', context)