コード例 #1
0
ファイル: views.py プロジェクト: roycohen2013/TheSquad
def view_profile(request, username=None):
    if request.user.is_anonymous():
        #tell user they need to be logged in to do that
        #add message flag that will display to user "you must be logged in to..."
        return HttpResponseRedirect(
            '/accounts/login/')  #redirect to login page
    else:
        if username is not None:
            try:
                userProfile = profileUtil.getProfileFromUser(
                    User.objects.get(username=username))
            except ObjectDoesNotExist:
                context = {}
                context['object'] = 'profile'
                context.update(content.genBaseLoggedIn(request))
                return render_to_response("dne.html", context)
        else:
            userProfile = profileUtil.getProfileFromUser(request.user)
        toolsOwned = toolUtil.getAllToolsOwnedBy(userProfile)
        toolsBorrowed = toolUtil.getAllToolsBorrowedBy(userProfile)
        sheds = shedUtil.getAllShedsJoinedBy(userProfile)
        context = {}
        context.update(csrf(request))
        context['currentUser'] = request.user
        context['userProfile'] = userProfile
        context['toolsOwned'] = toolsOwned
        context['toolsBorrowed'] = toolsBorrowed
        context['sheds'] = sheds
        context.update(content.genBaseLoggedIn(request))
        return render_to_response('view_profile.html', context)
コード例 #2
0
ファイル: views.py プロジェクト: roycohen2013/TheSquad
def view_profile(request, username=None):
    if request.user.is_anonymous():
        #tell user they need to be logged in to do that
        #add message flag that will display to user "you must be logged in to..."
        return HttpResponseRedirect('/accounts/login/') #redirect to login page
    else:
        if username is not None:
            try:
                userProfile = profileUtil.getProfileFromUser(User.objects.get(username=username))
            except ObjectDoesNotExist:
                context = {}
                context['object'] = 'profile'
                context.update(content.genBaseLoggedIn(request))
                return render_to_response("dne.html", context)
        else:
            userProfile = profileUtil.getProfileFromUser(request.user)
        toolsOwned = toolUtil.getAllToolsOwnedBy(userProfile)
        toolsBorrowed = toolUtil.getAllToolsBorrowedBy(userProfile)
        sheds = shedUtil.getAllShedsJoinedBy(userProfile)
        context = {}
        context.update(csrf(request))
        context['currentUser'] = request.user
        context['userProfile'] = userProfile
        context['toolsOwned'] = toolsOwned
        context['toolsBorrowed'] = toolsBorrowed
        context['sheds'] = sheds
        context.update(content.genBaseLoggedIn(request))
        return render_to_response('view_profile.html', context)
コード例 #3
0
 def __init__(self, tool, *args, **kwargs):
     self.toolObject = tool
     self.profileObject = self.toolObject.owner
     shedList = list(shedUtil.getAllShedsJoinedBy(self.profileObject))
     self.shedChoiceList = []
     for shed in shedList:
         self.shedChoiceList.append((shed.id, shed.name))
     super(ToolEditForm, self).__init__(*args, **kwargs)
     self.fields['name_'] = forms.CharField(required=True,
                                            initial=self.toolObject.name)
     self.fields['description_'] = forms.CharField(
         required=True, initial=self.toolObject.description)
     self.fields['tags_'] = forms.CharField(required=False,
                                            initial=self.toolObject.tags)
     self.fields['condition'] = forms.ChoiceField(choices = CONDITION_CHOICES, required = True, \
         initial=CONDITION_CHOICES[CONDITION_CHOICES.index((self.toolObject.condition, self.toolObject.conditionReadable))][0])
     self.fields['maximum_borrow_time'] = forms.IntegerField(max_value=60, min_value=1, required=False, \
     help_text = 'The maximum number of days a user is allowed to borrow this tool. 1-60 days.', \
     initial=self.toolObject.maxBorrowTime)
     self.fields['minimum_reputation'] = forms.IntegerField(max_value=100, min_value=0, required=False, \
     help_text = 'The minimum reputation required for a user to borrow this tool. 0-100.', \
     initial=self.toolObject.minimumReputation)
     self.fields['shed'] = forms.ChoiceField(choices=self.shedChoiceList, \
         initial=self.shedChoiceList[self.shedChoiceList.index((self.toolObject.myShed.id, self.toolObject.myShed.name))][0],\
         help_text = 'The shed this tool will be a part of.')
コード例 #4
0
ファイル: forms.py プロジェクト: roycohen2013/TheSquad
 def __init__(self, user, *args, **kwargs):
     self.userObject = user
     shedList = list(shedUtil.getAllShedsJoinedBy(profileUtil.getProfileFromUser(self.userObject)))
     self.shedChoiceList = []
     for shed in shedList:
         self.shedChoiceList.append((shed.id, shed.name))
     super(ToolCreationForm, self).__init__(*args, **kwargs)
     self.fields['shed'] = forms.ChoiceField(choices=self.shedChoiceList, help_text = 'The shed this tool will be a part of.')
コード例 #5
0
 def __init__(self, user, *args, **kwargs):
     self.userObject = user
     shedList = list(
         shedUtil.getAllShedsJoinedBy(
             profileUtil.getProfileFromUser(self.userObject)))
     self.shedChoiceList = []
     for shed in shedList:
         self.shedChoiceList.append((shed.id, shed.name))
     super(ToolCreationForm, self).__init__(*args, **kwargs)
     self.fields['shed'] = forms.ChoiceField(
         choices=self.shedChoiceList,
         help_text='The shed this tool will be a part of.')
コード例 #6
0
ファイル: content.py プロジェクト: roycohen2013/TheSquad
def genJustRegistered(account, profile):
    results = genSuper()
    results['username'] = account.username
    results['first_name'] = account.first_name
    results['last_name'] = account.last_name
    results['picture'] = None
    results['topSheds'] = None
    sheds = shedUtil.getAllShedsJoinedBy(profile)
    sharezone = profileUtil.getSharezone(profile)
    sharezoneMembers = profileUtil.getAllProfilesInSharezone(sharezone)
    #not done
    results['tools'] = None
    results['sheds'] = sheds
    results['borrowed'] = None
    results['sharezone'] = sharezone
    results['sharezoneMembers'] = sharezoneMembers
    return addGoodRegisterNoti(results)
コード例 #7
0
ファイル: content.py プロジェクト: roycohen2013/TheSquad
def genJustRegistered(account, profile):
	results = genSuper()
	results['username'] = account.username
	results['first_name'] = account.first_name
	results['last_name'] = account.last_name
	results['picture'] = None
	results['topSheds'] = None
	sheds = shedUtil.getAllShedsJoinedBy(profile)
	sharezone = profileUtil.getSharezone(profile)
	sharezoneMembers = profileUtil.getAllProfilesInSharezone(sharezone)
	#not done
	results['tools'] = None
	results['sheds'] = sheds
	results['borrowed'] = None
	results['sharezone'] = sharezone
	results['sharezoneMembers'] = sharezoneMembers
	return addGoodRegisterNoti(results)
コード例 #8
0
ファイル: views.py プロジェクト: roycohen2013/TheSquad
def all_sheds(request):
    if request.user.is_anonymous():
        return HttpResponseRedirect('/accounts/login')
    else:
        userProfile = profileUtil.getProfileFromUser(request.user)
        allSheds = shedUtil.getAllShedsAllSharezones()
        shedsInMySharezone = shedUtil.getAllShedsInSharezone(userProfile.sharezone)
        adminSheds = shedUtil.getAllShedsAdministratedBy(userProfile)
        ownedSheds = shedUtil.getAllShedsOwnedBy(userProfile)
        memberSheds = shedUtil.getAllShedsJoinedBy(userProfile)
        context = {}
        context.update(csrf(request))
        context['sheds'] = allSheds
        context['adminSheds'] = adminSheds
        context['ownedSheds'] = ownedSheds
        context['mySheds'] = memberSheds
        context.update(content.genBaseLoggedIn(request))
        return render_to_response('all_sheds.html', context)
コード例 #9
0
ファイル: content.py プロジェクト: roycohen2013/TheSquad
def genUserHome(request):
    results = genBaseLoggedIn(request)
    profile = profileUtil.getProfileFromUser(request.user)
    tools = toolUtil.getAllToolsOwnedBy(profile)
    sheds = shedUtil.getAllShedsJoinedBy(profile)
    #sheds = None
    borrowedTools = toolUtil.getAllToolsBorrowedBy(profile)
    #borrowedTools = None
    #print(profile)
    #results['notif'] = notifUtil.getAllActiveProfileNotifs(profile)
    sharezone = profileUtil.getSharezone(profile)
    sharezoneMembers = profileUtil.getAllProfilesInSharezone(sharezone)
    #not done
    results['tools'] = tools
    results['sheds'] = sheds
    results['borrowed'] = borrowedTools
    results['sharezone'] = sharezone
    results['sharezoneMembers'] = sharezoneMembers
    return results
コード例 #10
0
ファイル: content.py プロジェクト: roycohen2013/TheSquad
def genUserHome(request):
	results = genBaseLoggedIn(request)
	profile = profileUtil.getProfileFromUser(request.user)
	tools = toolUtil.getAllToolsOwnedBy(profile)
	sheds = shedUtil.getAllShedsJoinedBy(profile)
	#sheds = None
	borrowedTools = toolUtil.getAllToolsBorrowedBy(profile)
	#borrowedTools = None
	#print(profile)
	#results['notif'] = notifUtil.getAllActiveProfileNotifs(profile)
	sharezone = profileUtil.getSharezone(profile)
	sharezoneMembers = profileUtil.getAllProfilesInSharezone(sharezone)
	#not done
	results['tools'] = tools
	results['sheds'] = sheds
	results['borrowed'] = borrowedTools
	results['sharezone'] = sharezone
	results['sharezoneMembers'] = sharezoneMembers
	return results
コード例 #11
0
ファイル: views.py プロジェクト: roycohen2013/TheSquad
def all_sheds(request):
    if request.user.is_anonymous():
        return HttpResponseRedirect('/accounts/login')
    else:
        userProfile = profileUtil.getProfileFromUser(request.user)
        allSheds = shedUtil.getAllShedsAllSharezones()
        shedsInMySharezone = shedUtil.getAllShedsInSharezone(
            userProfile.sharezone)
        adminSheds = shedUtil.getAllShedsAdministratedBy(userProfile)
        ownedSheds = shedUtil.getAllShedsOwnedBy(userProfile)
        memberSheds = shedUtil.getAllShedsJoinedBy(userProfile)
        context = {}
        context.update(csrf(request))
        context['sheds'] = allSheds
        context['adminSheds'] = adminSheds
        context['ownedSheds'] = ownedSheds
        context['mySheds'] = memberSheds
        context.update(content.genBaseLoggedIn(request))
        return render_to_response('all_sheds.html', context)
コード例 #12
0
ファイル: forms.py プロジェクト: roycohen2013/TheSquad
 def __init__(self, tool, *args, **kwargs):
     self.toolObject = tool
     self.profileObject = self.toolObject.owner
     shedList = list(shedUtil.getAllShedsJoinedBy(self.profileObject))
     self.shedChoiceList = []
     for shed in shedList:
         self.shedChoiceList.append((shed.id, shed.name))
     super(ToolEditForm, self).__init__(*args, **kwargs)
     self.fields['name_'] = forms.CharField(required= True, initial=self.toolObject.name)
     self.fields['description_'] = forms.CharField(required= True, initial=self.toolObject.description)
     self.fields['tags_'] = forms.CharField(required= False, initial=self.toolObject.tags)
     self.fields['condition'] = forms.ChoiceField(choices = CONDITION_CHOICES, required = True, \
         initial=CONDITION_CHOICES[CONDITION_CHOICES.index((self.toolObject.condition, self.toolObject.conditionReadable))][0])
     self.fields['maximum_borrow_time'] = forms.IntegerField(max_value=60, min_value=1, required=False, \
     help_text = 'The maximum number of days a user is allowed to borrow this tool. 1-60 days.', \
     initial=self.toolObject.maxBorrowTime)
     self.fields['minimum_reputation'] = forms.IntegerField(max_value=100, min_value=0, required=False, \
     help_text = 'The minimum reputation required for a user to borrow this tool. 0-100.', \
     initial=self.toolObject.minimumReputation)
     self.fields['shed'] = forms.ChoiceField(choices=self.shedChoiceList, \
         initial=self.shedChoiceList[self.shedChoiceList.index((self.toolObject.myShed.id, self.toolObject.myShed.name))][0],\
         help_text = 'The shed this tool will be a part of.')