# Path: replayswithfriends/sc2match/views.py
# class MatchView(DetailView):
#     queryset = Match.share.all().select_related('playerresult', 'playerresult__player', 'message')
# 
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Match.share.available(self.request.user).select_related('playerresult', 'playerresult__player', 'message')
#         else:
#             return Match.share.public().select_related('playerresult', 'playerresult__player', 'message')
# 
# class MatchList(ListView):
#     queryset = Match.share.all()
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Match.share.available(self.request.user)
#         else:
#             return Match.share.public()
# 
# class PlayerList(ListView):
#     queryset = Player.objects.all()
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Player.objects.filter(match__in=Match.share.available(self.request.user))
#         else:
#             return Player.objects.filter(match__in=Match.share.public())
# 
# class PlayerDetail(DetailView):
#     queryset = Player.objects.all()
#     slug_field = 'username'
#     slug_url_kwarg = 'username'
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Player.objects.filter(match__in=Match.share.available(self.request.user))
#         else:
#             return Player.objects.filter(match__in=Match.share.public())
# 
# class MatchUpload(CreateView):
#     success_url = '/sc2/match/upload/'
#     form_class = MatchUploadForm
#     template_name = 'sc2match/upload.html'
#     queryset = Match.objects.all()
# 
#     def get_form_kwargs(self):
#         kw = super(MatchUpload, self).get_form_kwargs()
#         kw.update({'user': self.request.user})
#         return kw
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(MatchUpload, self).dispatch(*args, **kwargs)


from django.conf.urls.defaults import patterns, url
from replayswithfriends.sc2match.views import (MatchView, MatchList, PlayerList,
    PlayerDetail, MatchUpload)

urlpatterns = patterns('replayswithfriends.sc2match.views',
    url(r'^player/$', PlayerList.as_view(), name='player_list'),
    url(r'^player/(?P<pk>[\d]+)$', PlayerDetail.as_view(), name='player_detail'),
    url(r'^match/$', MatchList.as_view(), name='match_list'),

# Path: replayswithfriends/sc2match/views.py
# class MatchView(DetailView):
#     queryset = Match.share.all().select_related('playerresult', 'playerresult__player', 'message')
# 
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Match.share.available(self.request.user).select_related('playerresult', 'playerresult__player', 'message')
#         else:
#             return Match.share.public().select_related('playerresult', 'playerresult__player', 'message')
# 
# class MatchList(ListView):
#     queryset = Match.share.all()
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Match.share.available(self.request.user)
#         else:
#             return Match.share.public()
# 
# class PlayerList(ListView):
#     queryset = Player.objects.all()
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Player.objects.filter(match__in=Match.share.available(self.request.user))
#         else:
#             return Player.objects.filter(match__in=Match.share.public())
# 
# class PlayerDetail(DetailView):
#     queryset = Player.objects.all()
#     slug_field = 'username'
#     slug_url_kwarg = 'username'
#     def get_queryset(self):
#         if self.request.user.is_authenticated():
#             return Player.objects.filter(match__in=Match.share.available(self.request.user))
#         else:
#             return Player.objects.filter(match__in=Match.share.public())
# 
# class MatchUpload(CreateView):
#     success_url = '/sc2/match/upload/'
#     form_class = MatchUploadForm
#     template_name = 'sc2match/upload.html'
#     queryset = Match.objects.all()
# 
#     def get_form_kwargs(self):
#         kw = super(MatchUpload, self).get_form_kwargs()
#         kw.update({'user': self.request.user})
#         return kw
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(MatchUpload, self).dispatch(*args, **kwargs)


# Path: replayswithfriends/sc2match/urls.py
from django.conf.urls.defaults import patterns, url
from replayswithfriends.sc2match.views import (MatchView, MatchList, PlayerList,
    PlayerDetail, MatchUpload)


urlpatterns = patterns('replayswithfriends.sc2match.views',
    url(r'^player/$', PlayerList.as_view(), name='player_list'),
    url(r'^player/(?P<pk>[\d]+)$', PlayerDetail.as_view(), name='player_detail'),
    url(r'^match/$', MatchList.as_view(), name='match_list'),

    url(r'^match/(?P<pk>[\d]+)/$', MatchView.as_view(), name='match_detail'),