summaryrefslogtreecommitdiff
path: root/populate_issue.py
blob: 8ea103cedacb2644c85e83492b77b39e6c4523d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import datetime
from datetime import timedelta

Date = datetime.datetime.now()
def populate():
	
	f=open("issue_names.txt")
	for line in f:
		cname=line.replace("\n","")
		cat_added=add_category(cname)
	f.close()

def add_category(cname):
    cat = Issue.objects.get_or_create(name=cname,date_created=Date,date_modified=Date)[0]#for now description is same as category_names
    print "category " +str(cname)+" added at "+str(Date)
    return cat

# Start execution here!
if __name__ == '__main__':
    print "Starting population script for adding category..."
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'forums.settings')
    from website.models import *
    populate()