| 
									
										
										
										
											2017-08-31 15:20:08 +02:00
										 |  |  | from django.db.models import Q | 
					
						
							|  |  |  | from django.views.generic import ListView | 
					
						
							|  |  |  | from django.utils.translation import ugettext as _ | 
					
						
							| 
									
										
										
										
											2017-08-16 22:00:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-31 15:20:08 +02:00
										 |  |  | from .models import Game | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GameList(ListView): | 
					
						
							|  |  |  |     model = Game | 
					
						
							|  |  |  |     context_object_name = 'non_excluded_games' | 
					
						
							|  |  |  |     template_name = 'games/index.html' | 
					
						
							|  |  |  |     queryset = Game.objects.filter(~Q(status=Game.EXCLUDED)).order_by('name') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_context_data(self, **kwargs): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         Add playing games list | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         context = super(GameList, self).get_context_data(**kwargs) | 
					
						
							|  |  |  |         context['playing_games'] = Game.objects.filter( | 
					
						
							|  |  |  |             playing=True).order_by('name') | 
					
						
							|  |  |  |         return context |