Exemplo n.º 1
0
    #     returns List of centres to be added
    if centre_name == "Dombivali":
        return ["Borivali", "Ghatkopar", "Ville Parle"]
    if centre_name == "Borivali":
        return ["Dombivali", "Ghatkopar", "Ville Parle"]
    if centre_name == "Ghatkopar":
        return ["Dombivali", "Borivali", "Ville Parle"]
    if centre_name == "Ville Parle":
        return ["Dombivali", "Borivali", "Ghatkopar"]


center_name_list = ["Dombivali", "Borivali", "Ghatkopar", "Ville Parle"]
Mumbai = City.objects.get(name="Mumbai")
Mumbai_centres = Center.objects.filter(city=Mumbai)
Mumbai_members = Membership.objects.filter(center__in=Mumbai_centres)
print len(Mumbai_members)
for member in Mumbai_members:
    prof = member.ymht  # Profile
    current_center = member.center
    centre_name = current_center.center_name
    to_add_centers = centres_to_add(centre_name)
    for center in to_add_centers:
        new_member = Membership()
        new_member.ymht = prof
        new_member.center = Center.objects.get(center_name=center)
        new_member.age_group = member.age_group
        new_member.role = member.role
        new_member.since = member.since
        new_member.is_active = True
        new_member.save()
Exemplo n.º 2
0
def centres_to_add(centre_name):
#     returns List of centres to be added
    if centre_name == "Dombivali":
        return ["Borivali", "Ghatkopar", "Ville Parle"]
    if centre_name == "Borivali":
        return ["Dombivali", "Ghatkopar", "Ville Parle"]
    if centre_name == "Ghatkopar":
        return ["Dombivali", "Borivali", "Ville Parle"]
    if centre_name == "Ville Parle":
        return ["Dombivali", "Borivali", "Ghatkopar"]
    
center_name_list = ["Dombivali", "Borivali", "Ghatkopar", "Ville Parle"]
Mumbai = City.objects.get(name="Mumbai")
Mumbai_centres = Center.objects.filter(city=Mumbai)
Mumbai_members = Membership.objects.filter(center__in=Mumbai_centres)
print len(Mumbai_members)
for member in Mumbai_members:
    prof = member.ymht # Profile
    current_center = member.center
    centre_name = current_center.center_name
    to_add_centers = centres_to_add(centre_name)
    for center in to_add_centers:
        new_member = Membership()
        new_member.ymht = prof
        new_member.center = Center.objects.get(center_name=center)
        new_member.age_group = member.age_group
        new_member.role = member.role
        new_member.since = member.since
        new_member.is_active = True
        new_member.save()
Exemplo n.º 3
0
        prof = profile.objects.get(user=current_user)
    except:
        prof = profile()
        prof.user = User.objects.get(username=row[0])
    prof.first_name = row[1]
    prof.last_name = row[2]
    prof.date_of_birth = datetime.date.today()
    prof.save()
    prof.hobby = [Hobby.objects.get(id=1)]
    prof.father_name = "Please input"
    prof.mother_name = "Please input"
    prof.save()
    try:
        member = Membership.objects.get(ymht=prof)
    except:
        member = Membership()
        member.ymht = prof
    member.center = Center.objects.get(center_name=row[3])
    member.age_group = AgeGroup.objects.get(age_group=row[4])
    member.role = Role.objects.get(role=row[5])
#     member.sub_role = Subrole.objects.filter() # Add code to insert subroles 
    member.since = datetime.date.today()
    member.is_active = True
    member.save()
    if row[6]:
        member.sub_role.add(SubRole.objects.get(sub_role="PR"))
    if row[7]:
        member.sub_role.add(SubRole.objects.get(sub_role="Admin"))
    if row[8]:
        member.sub_role.add(SubRole.objects.get(sub_role="Academics"))
    if row[9]: