示例#1
0
 def setUp(self):
     try:
         self.genInfoNotif = notifUtils.createInfoNotif(
             Tool.objects.get(name="Hoe"),
             profUtils.getProfileFromUsername("TaikhoomAttar"),
             "Synergy is love, synergy is life")
     except:
         self.fail("Error in info notification generation!")
示例#2
0
def add_shed_admin(request, id, username):
    if request.user.is_anonymous():
        return HttpResponseRedirect('/accounts/login')
    else:
        userProfile = profileUtil.getProfileFromUser(request.user)
        shedObj = shedUtil.getShedFromID(id)
        newAdmin = profileUtil.getProfileFromUser(User.objects.get(username=username))
        admins = shedUtil.getAllAdminsOfShed(shedObj)
        isAdmin = False
        for admin in admins:
            if admin == userProfile:
                isAdmin = True
        if isAdmin:
            shedObj.admins.add(newAdmin)
            notifUtil.createInfoNotif(shedObj, newAdmin, "You have been made an admin of the shed " + shedObj.name + "! ")
            return HttpResponseRedirect("/sheds/" + str(shedObj.id) + "/add_admin/added/success")
        else:
            return HttpResponseRedirect('/')
示例#3
0
	def test_notif_creation (self):
		"""
		"""
		tool = Tool.objects.get(name = "Hoe")
		#print (tool.name)
		prof = profUtils.getProfileFromUsername ("TaikhoomAttar")
		msg = "Synergy is love, synergy is life"
		generation = notifUtils.createInfoNotif (tool, prof, msg)
		self.assertEqual (tool, generation.source)
		self.assertEqual (prof, generation.recipient)
		self.assertEqual (msg, generation.content)
示例#4
0
def add_shed_admin(request, id, username):
    if request.user.is_anonymous():
        return HttpResponseRedirect('/accounts/login')
    else:
        userProfile = profileUtil.getProfileFromUser(request.user)
        shedObj = shedUtil.getShedFromID(id)
        newAdmin = profileUtil.getProfileFromUser(
            User.objects.get(username=username))
        admins = shedUtil.getAllAdminsOfShed(shedObj)
        isAdmin = False
        for admin in admins:
            if admin == userProfile:
                isAdmin = True
        if isAdmin:
            shedObj.admins.add(newAdmin)
            notifUtil.createInfoNotif(
                shedObj, newAdmin, "You have been made an admin of the shed " +
                shedObj.name + "! ")
            return HttpResponseRedirect("/sheds/" + str(shedObj.id) +
                                        "/add_admin/added/success")
        else:
            return HttpResponseRedirect('/')
示例#5
0
 def setUp (self):
     try:
     	self.genInfoNotif = notifUtils.createInfoNotif (Tool.objects.get(name = "Hoe"), profUtils.getProfileFromUsername ("TaikhoomAttar"), "Synergy is love, synergy is life")
     except:
     	self.fail ("Error in info notification generation!")