Exemple #1
0
 def generate_discussions(self, include_staff):
    """generate some random discussions"""
    if DEBUG is False:
       return 0
    
    # get the super user to assign to content
    try:
       u = User.objects.get(pk=1)
    except User.DoesNotExist:
       return -1
    
    # generate 55 discussions
    n = 50
    log=list()
    for i in range(0, n):
       # TODO: get random text
       body_text = random_snatcher(PROJECT_PATH + '/resources/moby_dick.html', i, '<p>', '</p>')
       d = Discussion(
             title=body_text[:30],
             body=body_text,
             user=u
       )
       d.save()
       log.append("created %s" % d.title)
    return log
Exemple #2
0
 def save(self, request, gid=None):
     """create a new discussion"""
     data = request.POST.copy()
     u = request.user
     new = Discussion(
         title=data['title'],
         body=data['body'],
         type=data['type'],
         user=u,
     )
     new.save()
     
     save_group(new, gid, data)
     
     save_taxon('discussion', data['terms'], new)
     return new