Ejemplo n.º 1
0
def new_topic(blogid, user, passwd, struct, publish):
    '''Add one topic'''

    if not has_auth(user, passwd):
        raise Fault(-1, "Authentication Failure")

    title = st(struct.get('title', "No Title"), 'utf-8')
    markup = struct.get('markup', "markdown")

    topic = Topic(name=title, markup=markup)
    topic.updated = datetime.now()

    ca = st(struct['category'], 'utf-8')
    catalog = Catalog.objects.get(name=ca)
    topic.catalog = catalog

    # find which user
    topic.user = User.objects.get(username=user)
    topic.save()
    catalog.last_topic = topic
    catalog.topic_count += 1
    catalog.save()

    text = struct.get('description', "Nothing")
    topic.save_file(st(text, 'utf-8'))
    return topic.id
Ejemplo n.º 2
0
def new_topic(blogid, user, passwd, struct, publish):
    '''Add one topic'''

    if not has_auth(user, passwd):
        raise Fault(-1, "Authentication Failure")

    title = st(struct.get('title', "No Title"), 'utf-8')
    markup = struct.get('markup', "markdown")

    topic = Topic(name=title, markup=markup)
    topic.updated = datetime.now()

    ca = st(struct['category'], 'utf-8')
    catalog = Catalog.objects.get(name=ca)
    topic.catalog = catalog

    # find which user
    topic.user = User.objects.get(username=user)
    topic.save()
    catalog.last_topic = topic
    catalog.topic_count += 1
    catalog.save()

    text = struct.get('description', "Nothing")
    topic.save_file(st(text, 'utf-8'))
    return topic.id
Ejemplo n.º 3
0
 def save(self):
     topic = Topic(name=self.cleaned_data['name'],
                   user_ip=self.user_ip,
                   markup=self.cleaned_data['markup'])
     topic.catalog = self.catalog
     topic.user = self.user
     topic.updated = datetime.datetime.now()
     topic.save()
     self.catalog.topic_count += 1
     self.catalog.save()
     text = self.cleaned_data['text'].encode('utf8')
     topic.save_file(text)
     return topic