Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. class CalendarView(generic.TemplateView):                                                          
  2.                                                                                                    
  3.     def get(self, request):                                                                        
  4.         # use today's date for the calendar                                                        
  5.         d = get_date(self.request.GET.get('month', None))                                          
  6.                                                                                                    
  7.         url = "http://localhost/v1/una_api/"                                                      
  8.         params = {'event_year': d.year, 'event_month': d.month}                                    
  9.         r = requests.get(url, params=params)                                                        
  10.         events = r.json()                                                                          
  11.                                                                                                    
  12.         # Instantiate our calendar class with today's year and date                                
  13.         cal = Calendar(d.year, d.month)                                                            
  14.                                                                                                    
  15.         # Call the formatmonth method, which returns our calendar as a table                        
  16.         html_cal = cal.formatmonth(events=events['results'], withyear=True)                        
  17.         context = {'calendar': mark_safe(html_cal), 'prev_month': prev_month(d), 'next_month': next_month(d)}
  18.                                                                                                    
  19.         return render(request, "cal/calendar.html", context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement