def index(request, year=date.today().year, month=date.today().month): # t = date.today() # month = date.strftime(t, '%b') # year = t.year year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "MyClub Event Calendar - %s %s" % (month_name,year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse("<h1>MyClub Event Calendar</h1>") # return HttpResponse("<h1>%s</h1>" % title) # return HttpResponse("<h1>%s</h1><p>%s</p>" % (title, cal)) # return render(request, 'base.html', {'title': title, 'cal': cal}) cal = HTMLCalendar().formatmonth(year, month) announcements = [ { 'date': '6-10-2020', 'announcement': "Club Registrations Open" }, { 'date': '6-15-2020', 'announcement': "Joe Smith Elected New Club President" } ] return render(request, 'events/calendar_base.html', {'title': title, 'cal': cal, 'announcements': announcements} )
def home(request, year=datetime.now().year, month=datetime.now().strftime("%B")): name = "Manan" # Convert Month From Name to Number month = month.capitalize() month_number = list(calendar.month_name).index(month) month_number = int(month_number) # Create The Calendar cal = HTMLCalendar().formatmonth(year, month_number) # Get Current Year now = datetime.now() current_year = now.year # Get Current Time time = now.strftime("%I:%M %p") return render(request, "events/home.html", { "name": name, "year": year, "month": month, "month_number": month_number, "cal": cal, "current_year": current_year, "time": time, })
def home(request, year=datetime.now().year, month=datetime.now().strftime('%B')): name = "john" month = month.capitalize() month_number = list(calendar.month_name).index(month) month_number = int(month_number) cal = HTMLCalendar().formatmonth(year, month_number) #get currnet year now = datetime.now() current_year = now.year #get current time time = now.strftime('%I:%M %p') return render( request, 'polls/home.html', { 'name': name, 'year': year, 'month': month, 'month_number': month_number, 'cal': cal, 'current_year': current_year, 'time': time })
def home(request, year=datetime.now().year, month=datetime.now().strftime('%B')): name = "Rokas" month = month.capitalize() # Convert month name to number month_number = list(calendar.month_name).index(month) month_number = int(month_number) # crate calendar cal = HTMLCalendar().formatmonth( year, month_number, ) # get current year now = datetime.now() current_year = now.year # get current time time = now.strftime('%I:%M %p') return render(request, 'events/home.html', { "name": name, "year": year, "month": month, "month_number": month_number, "cal": cal, "current_year": current_year, "time": time, })
def MyCalView(request): y = 2019 m = 6 nik = "- %s %s" % ('NOV', y) cal = HTMLCalendar().formatyear(y, m) dic = {'nik': nik, 'cal': cal} return render(request, 'WebApp/Cal.html', context=dic)
def month_cal(year, month, month_iter=0): '''generates a month formatted calender from python standard calender lib based on provided month, year Arguments: year {date object} -- python datetime.datetime.now().year month {date object} -- python datetime.datetime.now().month Keyword Arguments: month_iter {int} -- iterater for creating months in the future from datetime.now() (default: {0}) Returns: htmlstring -- html string calendar formatted by month ''' now = datetime.datetime.now() cal = HTMLCalendar(firstweekday=6) cal = cal.formatmonth(theyear=year, themonth=month + month_iter, withyear=True) cal = cal.replace( '<table ', '<table data-month={0} data-year={1} cellpadding="10" cellspacing="10" class="m-2 text-center month" border="2" ' .format(month + month_iter, year)) if month_iter != 0 or year != now.year: cal = cal.replace( '<table ', '<table hidden data-month={0} data-year={1} cellpadding="10" cellspacing="10" class="m-2 text-center month" border="2" ' .format(month + month_iter, year)) return cal
def changelist_view(self, request, extra_context=None): after_day = request.GET.get('day__gte', None) extra_context = extra_context or {} if not after_day: d = datetime.date.today() else: try: split_after_day = after_day.split('-') d = datetime.date(year=int(split_after_day[0]), month=int(split_after_day[1]), day=1) except: d = datetime.date.today() previous_month = datetime.date(year=d.year, month=d.month, day=1) # find first day of current month previous_month = previous_month - datetime.timedelta(days=1) # backs up a single day previous_month = datetime.date(year=previous_month.year, month=previous_month.month, day=1) # find first day of previous month last_day = calendar.monthrange(d.year, d.month) next_month = datetime.date(year=d.year, month=d.month, day=last_day[1]) # find last day of current month next_month = next_month + datetime.timedelta(days=1) # forward a single day next_month = datetime.date(year=next_month.year, month=next_month.month, day=1) # find first day of next month extra_context['previous_month'] = reverse('admin:events_event_changelist') + '?day__gte=' + str( previous_month) extra_context['next_month'] = reverse('admin:events_event_changelist') + '?day__gte=' + str(next_month) cal = HTMLCalendar() html_calendar = cal.formatmonth(d.year, d.month, withyear=True) html_calendar = html_calendar.replace('<td ', '<td width="150" height="150"') extra_context['calendar'] = mark_safe(html_calendar) return super(EventAdmin, self).changelist_view(request, extra_context)
def home(request, year=datetime.now().year, month=datetime.now().strftime('%B')): name = "John" month = month.capitalize() # Convert month from name to number month_number = list(calendar.month_name).index(month) month_number = int(month_number) # create a calendar cal = HTMLCalendar().formatmonth( year, month_number) # Get current year now = datetime.now() current_year = now.year # Query the Events Model For Dates event_list = Event.objects.filter( event_date__year = year, event_date__month = month_number ) # Get current time time = now.strftime('%I:%M %p') return render(request, 'events/home.html', { "name": name, "year": year, "month": month, "month_number": month_number, "cal": cal, "current_year": current_year, "time":time, "event_list": event_list, })
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # context['object_list'] = Post.objects.all() year = datetime.now().year month = datetime.now().strftime('%B') month = month.capitalize() # Convert month from name to number month_number = list(calendar.month_name).index(month) month_number = int(month_number) # create a calendar cal = HTMLCalendar().formatmonth(year, month_number) # Get current year now = datetime.now() current_year = now.year # Get current time time = now.strftime('%I:%M:%S %p') # context["year"] = year context.update({ "year": year, "month": month, "month_number": month_number, "cal": cal, "current_year": current_year, "time": time, }) return context
def index(request, year=date.today().year, month=date.today().month): # t = date.today() # month = date.strftime(t, '%b') # year = t.year # usr = request.user # ses = request.session # path = request.path # path_info = request.path_info # headers = request.headers # assert False year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "CMMA Event Calendar - %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) announcements = [{ 'date': '6-10-2020', 'announcement': "Registrations Open" }, { 'date': '6-15-2020', 'announcement': "Website accessible online." }] # return HttpResponse("<h1>%s</h1><p>%s</p>" % (title, cal)) # return render(request, return TemplateResponse(request, 'events/calendar_base.html', { 'title': title, 'cal': cal, 'announcements': announcements })
def Calendar(request): # get corrent year now = datetime.now() current_year = now.year month = now.month year = now.year # convert month from name to number # month_number = list(calendar.month_name).index(month) # month_number = int(month_number) # create a calendar cal = HTMLCalendar().formatmonth( year, month ) # get current time time = now.strftime('%I:%M %p') return render(request, 'notes/calendar.html', { "year": year, "month": month, # "month_number": month_number, "cal": cal, "current_year": current_year, "time": time })
def index(request,year=date.today().year,month=date.today().month): #year and month are added because of the urls.py int and str path converters year=int(year) month=int(month) if year < 1900 or year > 2099 : year=date.today().year month_name=calendar.month_name[month] #month_name func from the cal module to get month name that matches month number. cal=HTMLCalendar().formatmonth(year,month) #retrieve html formatted cal return render(request,'calendar_base.html',{'cal':cal})
def index(request, year=date.today().year, month=date.today().month): # usr = request.user # ses = request.session # paht = request.path # path_info = request.path_info # headers = request.headers # assert False announcements = [{ 'date': '6-10-2020', 'announcement': 'Club Registration Open' }, { 'date': '6-15-2020', 'announcement': 'John Smith Elected new President' }] year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = 'My Club Event Calendar - %s %s' % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse('<h1>%s</h><p>%s</p>' % (title, cal)) return TemplateResponse(request, 'upcomingevents/index.html', { 'title': title, 'cal': cal, 'announcements': announcements })
def sepcified_date(request, year, month_number): month = month_name[int(month_number)] page_title = f'Events Notifier - {month[0:3]},{year}' calender_html = HTMLCalendar().formatmonth(int(year), int(month_number)) month_list = [{int(month_number) + x + 1: month_dictionary[int(month_number) + x + 1]} for x in range(12 - int(month_number))] # return HttpResponse(f"<h2>{page_title}</h2><p>{calender_html}</p>") return render(request, 'events/calender_base.html', {'page_title': page_title, 'calender_html': calender_html, 'month': month_list, 'year': year})
def calender(request, year=date.today().year, month=date.today().month): year = int(year) month = int(month) if year < 1900 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "MyClub Event Calendar - %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse("<h1>%s</h1><p>%s</p>" % (title, cal)) return render(request, 'music/calender.html', {'title': title, 'cal': cal})
def show_calendar(request): my_month = date.today().month start_year = date.today().year cal = HTMLCalendar().formatmonth(start_year, my_month) pirmas = request.session['room_id'] return render(request, 'mycalendar.html', { 'my_calendar': cal, 'tet': pirmas })
def index(request, year=date.today().year, month=date.today().month): year = int(year) month = int(month) if year < 1900 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "MyClub Event Calendar - %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) return HttpResponse("<h1>%s</h1><p>%s</p>" % (title, cal))
def index(request, year=date.today().year, month=date.today().month): year = int(year) month = int(month) if year < 1900 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "Welcome to Botza Sentiment Analysis- %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse("Hello, world. You're at the polls index.") return render(request, 'index.html', {'title': title, 'cal': cal})
def render(self, context): try: my_year = self.year.resolve(context) my_month = self.month.resolve(context) cal = HTMLCalendar() return cal.formatmonth(int(my_year), int(my_month)) except ValueError: return except template.VariableDoesNotExist: return
def index(request, year=datetime.date.today().year, month=datetime.date.today().month): year = int(year) month = int(month) if year < 1980 or year > 2099: year = datetime.date.today().year month_name = calendar.month_name[month] title = f"Web Project calendar for the month of {month_name}:{year}" cal = HTMLCalendar().formatmonth(year, month) return render(request, 'base.html', {'title': title, 'cal': cal})
def default_home(request): day_variable = date.today() month = date.strftime(day_variable, '%b') year = day_variable.year page_title = f"Events Notifier - {month},{year}" calender_html = HTMLCalendar().formatmonth(year, day_variable.month) # return HttpResponse(f"<h2>{page_title}</h2><p>{calender_html}</p>") current_month = date.today().month month_list = [{current_month + x + 1: month_dictionary[current_month + x + 1]} for x in range(12 - current_month)] return render(request, 'events/calender_base.html', {'page_title': page_title, 'calender_html': calender_html, 'month': month_list, 'year': year})
def calbuilder(request): year = int(request.POST.get('year', None)) month = int(request.POST.get('month', None)) cal = HTMLCalendar(calendar.SUNDAY) cal = cal.formatmonth(year, month) cal = cal.replace('<td ', '<td width="150" height="150"') cal = cal.replace( 'border="0" cellpadding="0" cellspacing="0" class="month">', 'class="table">') events = Event.objects.filter(date__year=year, date__month=month) events_json = serializers.serialize('json', events) context = {'calendar': cal, 'events': events_json} return HttpResponse(json.dumps(context), content_type="application/json")
def blog(request, post_id=1): if not (request.user.is_authenticated()): request.user.username = '******' c = HTMLCalendar(6).formatmonth(date.today().year, date.today().month) c = c.replace('>%s</td>' % date.today().day, '><u><a href=#>%s</a></u></td>' % date.today().day) return render_to_response( 'blog.html', { 'post': Post.objects.get(id=post_id), 'user': request.user, 'calendar': c, })
def index(request, year=date.today().year, month=date.today().month): # t = date.today() # month = date.strftime(t, '%b') # year = t.year year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "MyClub Event Calendar - %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse("<h1>MyClub Event Calendar</h1>") # return HttpResponse("<h1>%s</h1>" % title) return HttpResponse("<h1>%s</h1><p>%s</p>" % (title, cal))
def index(request, year=date.today().year, month=date.today().month): # t = date.today() # month = date.strftime(t, '%b') # year = t.year year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = 'MyClub Event Calendar - %s %s' % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse('<h1>%s</h1><p>%s</p>' % (title, cal)) return render(request, 'base.html', {'title': title, 'cal': cal})
def blogs(request): if not (request.user.is_authenticated()): request.user.username = '******' c = HTMLCalendar(6).formatmonth(date.today().year, date.today().month) c = c.replace('>%s</td>' % date.today().day, '><u><a href=#>%s</a></u></td>' % date.today().day) return render_to_response( 'blogs.html', { 'blogs': Post.objects.all().order_by('-published_date'), 'user': request.user, 'calendar': c, }, context_instance=RequestContext(request))
def index(request, year=date.today().year, month=date.today().month): # t = date.today() # month = date.strftime(t, '%b') # year =t.year month = int(month) year = int(year) if year < 1900 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "Myclub event calendar-- %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) # return HttpResponse("<h1>%s</h1><p>%s</p>"%(title,cal)) return render(request, 'calendar_base.html', {'title': title, 'cal': cal})
def index(request, year=date.today().year, month=date.today().month): """ Passes title and calendar to base.html template """ year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_str = calendar.month_name[month] title = f'Myclub Event Calendar - {month_str}, {year}' cal = HTMLCalendar().formatmonth(year, month) return render(request, 'events/calendar_base.html', { 'title': title, 'cal': cal }) # returns HTML template
def index(request, year=date.today().year, month=date.today().month): year = int(year) month = int(month) if year < 2000 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "Myclub Event calender - %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) announcements = [{ 'date': '6-10-2020', 'announcement': "Club Registrations Open" }, { 'date': '6-15-2020', 'announcement': "Joe Smith Elected New Club President" }] context = {'title': title, 'cal': cal, 'announcements': announcements} return render(request, 'events/calendar_base.html', context)
def index(request, year=date.today().year, month=date.today().month): year = int(year) month = int(month) if year < 1900 or year > 2099: year = date.today().year month_name = calendar.month_name[month] title = "MyClub Event Calendar - %s %s" % (month_name, year) cal = HTMLCalendar().formatmonth(year, month) announcements = [ { 'date': '8-10-2019', 'announcement': "Club Registrations Open" }, { 'date': '8-15-2019', 'announcement': "Joe Smith Elected New Club President" } ] return render(request, 'templating/index.html', {'title': title, 'cal': cal, 'announcements': announcements})