Ejemplo n.º 1
0
def alojamiento(request,ident):
    if request.user.is_authenticated():
        logged = True
        try:
            usersel = UserSels.objects.get(user=request.user.username,alojamiento_id=ident)
        except UserSels.DoesNotExist:
            usersel = UserSels(user=request.user.username, date = datetime.datetime.now(), alojamiento_id=ident)
            usersel.save()
    else:
        logged = False
    if request.method == 'POST':
        alojamiento = Alojamientos.objects.get(id=int(ident))
        comment = Comments(text = request.POST['comment'], date = datetime.datetime.now(), alojamiento_id = int(ident))
        comment.save()
    try:
        alojamiento = Alojamientos.objects.get(id=ident)
    except Alojamientos.DoesNotExist:
        return HttpResponse("El alojamiento al que intentas acceder no esta disponible")
    images = Images.objects.filter(alojamiento_id=ident)
    template = get_template('alojamiento.html')
    context = ({'home': request.get_host(),
                'username': request.user.username,
                'logged': logged,
                'alojamiento': alojamiento,
                'images': images})
    return HttpResponse(template.render(context))
Ejemplo n.º 2
0
    def post(self):
        cookie_user = self.get_user_from_cookie()

        if cookie_user:
            post_id = self.request.get('postID')
            comment_id = self.request.get('commentID')
            comment_str = self.request.get('comment_str')
            if post_id and comment_id and comment_str:
                commentObj = Comments.get_by_id(int(comment_id))
                if commentObj:
                    commentObj.comment = comment_str
                    commentObj.put()
                    time.sleep(0.2)
                    commentObj = Comments.get_by_id(int(comment_id))
                    self.write(
                        json.dumps(({
                            'comment_str': commentObj.comment
                        })))
                    # self.redirect('/blog/%s'%post_id)
                else:
                    self.error(404)
            else:
                self.error(404)
                return
        else:
            cookie_error = 'You have to be logged in to edit a comment!'
            self.render('login.html', cookie_error=cookie_error)
Ejemplo n.º 3
0
def submit_comment_poopstream():
    comment = request.json['comment']
    commenter_id = request.json['session_id']
    comment_time = datetime.utcnow()
    comment_message = request.json['message']
    if comment != '':
        if commenter_id == '':
            commenter_id = 'Anonymous'
            new_comment = Comments(comment=comment,
                                   commenter_name=commenter_id,
                                   comment_time=comment_time,
                                   comment_message=comment_message)
            db.session.add(new_comment)
            db.session.commit()
            return jsonify(success=True)
        else:
            find_user_name = Users_v2.query.filter_by(
                id=commenter_id).first().username
            new_comment = Comments(comment=comment,
                                   commenter_name=find_user_name,
                                   comment_time=comment_time,
                                   comment_message=comment_message)
            db.session.add(new_comment)
            db.session.commit()
            return jsonify(success=True)
    return jsonify(success=False)
def home(request):
    blog_posts = load_blog()
    results = []
    archieves = []
    for blog in blog_posts:
       body = blog.body
       new_list = [m.start() for m in re.finditer(r"<br />",body)]
       new_line = body.index('<br />')
       for item in new_list:
               if item >= 750:
                  new_line = item
                  break;
       body = body[:new_line]
       pre_start_list = [m.start() for m in re.finditer(r"<pre ",body)]
       pre_end_list = [m.start() for m in re.finditer(r"</pre>",body)]
       if pre_start_list:
            if not pre_end_list:
              pre_end = [m.start() for m in re.finditer(r"</pre>",blog.body)][0]
              body =  blog.body[:pre_end]
       archieves.append(blog.title)
       date = blog.day[:10]
       day = date[8:10]
       month = date[5:7]
       mnth = get_month(month)
       results.append({'day': day, 'month': mnth, 'body': body, 'title': blog.title})
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
           data = form.cleaned_data
           p = Comments(name=data['name'], comment=data['comment'], title=request.POST['post_title'])
           p.save()
    comments = Comments.objects.order_by("-id")
    return render(request, 'home.html', {'posts': results, 'outline': archieves,  'comments': comments, 'form':CommentForm})
Ejemplo n.º 5
0
 def post(self, slug):
     comment = self.get_body_argument('comment')
     if comment == "":
         return self.redirect('/post/{}'.format(slug))
     user = self.current_user
     Comments.create(user_id=user.id, post_id=slug, comment=comment)
     return self.redirect("/post/{}".format(slug))
Ejemplo n.º 6
0
    def post(self):
        user_id = None
        commentId = None
        # AUTHENTICATE check for valid cookie
        user_id = auth(self.request.cookies.get('user_id'))
        commentId = self.request.get("commentId")
        comment = self.request.get("comment")
        postId = self.request.get("postId")

        q = BlogEntry.get_by_id(int(postId))
        k = q.key()

        if user_id:
            commentId = int(commentId)
            comEntity = Comments.get_by_id(commentId, parent=k)

            if user_id == comEntity.author_id:
                q = BlogEntry.get_by_id(int(postId))
                if q:
                    k = q.key()
                    c = Comments.get_by_id(int(commentId), parent=k)
                    if c:
                        c.comment = comment
                        c.put()
                        error = ""
                        self.redirect("/focus?postId=%s&error=%s" %
                                      (postId, error))
            else:
                error = "You must be the author to edit the comment."
                self.redirect("/focus?postId=%s&error=%s" % (postId, error))
        else:
            error = "You must be loggen in to edit the comment."
            self.redirect("/focus?postId=%s&error=%s" % (postId, error))
Ejemplo n.º 7
0
    def post(self, paper_id):
        logging.info('QQQ: Comment Create POST')

        RefObjID=self.request.get('RefObjID')
        CreatedBy = users.get_current_user()

        q = Comments.query(Comments.RefObjType == 'paper', Comments.RefObjID == paper_id).order(-Comments.CommentCode)
        comments = q.get()

        try:
            if comments.CommentCode:
                CommentCodeX = chr(ord(comments.CommentCode[0]) + 1)
            else:
                CommentCodeX = 'A'
        except AttributeError:
                CommentCodeX = 'A'

        n = Comments(Title=self.request.get('Title'),
                RefObjType=self.request.get('RefObjType'),
                RefObjID=RefObjID,
                CommentCode=CommentCodeX,
                IndentClass=len(CommentCodeX),
                Text=self.request.get('Text'),
                Status='Published',
                CreatedBy=CreatedBy,
                StatusBy=CreatedBy)
        n.put()

        x = self.redirect('/papers/display/' + paper_id)
        return x
Ejemplo n.º 8
0
def add_comment():
    comment = request.form.get('comment')
    life_id = request.form.get('life_id')
    '''算法开始'''
    index_now = compute_model(comment)
    print(str(index_now))
    life = Life.query.filter(Life.id == life_id).first()
    author = User.query.filter(User.id == life.author_id).first()
    character = Characters.query.filter(
        Characters.user_id == author.id).first()
    if character.rank:
        string = float(character.rank)
        string += index_now
        character.rank = str(string)
        db.session.commit()
    else:
        character.rank = str(index_now)
        db.session.commit()
    '''算法结束'''
    comments = Comments(content=comment)
    comments.life_id = life_id
    user_id = session.get('user_id')
    comments.user_id = user_id
    db.session.add(comments)
    db.session.commit()
    return redirect(url_for('details', life_id=life_id))
Ejemplo n.º 9
0
def alojamiento(request, ident):
    if request.user.is_authenticated():
        logged = True
        try:
            usersel = UserSels.objects.get(user=request.user.username,
                                           alojamiento_id=ident)
        except UserSels.DoesNotExist:
            usersel = UserSels(user=request.user.username,
                               date=datetime.datetime.now(),
                               alojamiento_id=ident)
            usersel.save()
    else:
        logged = False
    if request.method == 'POST':
        alojamiento = Alojamientos.objects.get(id=int(ident))
        comment = Comments(text=request.POST['comment'],
                           date=datetime.datetime.now(),
                           alojamiento_id=int(ident))
        comment.save()
    try:
        alojamiento = Alojamientos.objects.get(id=ident)
    except Alojamientos.DoesNotExist:
        return HttpResponse(
            "El alojamiento al que intentas acceder no esta disponible")
    images = Images.objects.filter(alojamiento_id=ident)
    template = get_template('alojamiento.html')
    context = ({
        'home': request.get_host(),
        'username': request.user.username,
        'logged': logged,
        'alojamiento': alojamiento,
        'images': images
    })
    return HttpResponse(template.render(context))
Ejemplo n.º 10
0
 def post(self, post_id):
     renderComment = RenderComment()
     render = RenderPost()
     login = self.read_cookie('login')
     uid = None
     if login:
         uid = int(login)
         user = Users.get_by_id(uid)
     content = self.request.get("content")
     post = Post.get_by_id(int(post_id))
     likes = post.likes.count()
     comments = post.comments.order("-date")
     if uid:
         if content:
             comment = Comments(post=post, user=user, content=content)
             comment.put()
             self.redirect("/blog/" + post_id)
         else:
             self.render("permalink.html",
                         post=post,
                         error="",
                         likes=likes,
                         render=render,
                         comment_error="Type something!",
                         renderComment=renderComment,
                         comments=comments)
     else:
         self.render("permalink.html",
                     post=post,
                     error="",
                     likes=likes,
                     render=render,
                     comment_error="you must be logged in",
                     renderComment=renderComment,
                     comments=comments)
Ejemplo n.º 11
0
def get_comments(ref_id, next_id=None, limit=100):
    if next_id:
        return Comments.select(
            'where ref_id=? and _id<? order by _id desc limit ?', ref_id,
            next_id, limit)
    return Comments.select('where ref_id=? order by _id desc limit ?', ref_id,
                           limit)
Ejemplo n.º 12
0
def submitcomment(request, name):
	#get form data
	user = request.POST['user']
	comment = request.POST['comment']
	prof = Professors.objects.get(name = name) #get professor we are talking about
	comm = Comments(professor=prof,user=user,comment=comment) #create Comment entry
	comm.save() #insert into database
	return redirect('/data/' + name) #display the new data on the professor's page
Ejemplo n.º 13
0
def _get_comments_from_soup(hotel_id, soup):
    for so in soup.find_all(attrs={'class': 'J_commentDetail'}):
        if so.text:
            try:
                Comments.create(hotel_id=hotel_id, comment=so.text.encode('utf-8'))
                # print so.text.encode('utf-8')
            except Exception, e:
                print so.text.encode('utf-8'), e
Ejemplo n.º 14
0
def addComment(request):
    author = User.objects.get(id=request.user.id)
    content = request.POST.get("content",str).encode("utf-8")
    makeTime = datetime.now()
    postNum = Posts.objects.get(id=request.POST.get("postNum"))
    delPw = request.POST.get("delPw",str).encode("utf-8")
    newComment = Comments(author=author,content=content,makeTime=makeTime,postNum=postNum,delPw = delPw)
    newComment.save()
    return HttpResponse()
Ejemplo n.º 15
0
def _get_comments_by_page():
    """

    :return:users, page
    """
    total = Comments.count_all()
    page = Page(total, _get_page_index(), 5)
    comments = Comments.find_by('order by comment_date desc limit ?,?', page.offset, page.limit)
    return comments, page
Ejemplo n.º 16
0
 def create_comment(user):
     body = request.get_json()
     print(body)
     new_comment = Comments(text=body['text'],
                            user_id=user['user']['id'],
                            recipe_id=body['recipe_id'])
     print(new_comment)
     db.session.add(new_comment)
     db.session.commit()
     return jsonify(new_comment.serialize()), 201
Ejemplo n.º 17
0
 def get(self, slug):
     comment = Comments.select().where(Comments.id == slug)
     if comment:
         comment = Comments.select().where(Comments.id == slug).get()
         user = self.current_user
         # Only allow the creator of the comment access to edit
         if comment.user_id == user.id:
             return self.render_template("edit_comment.html",
                                         {'comment': comment})
     return self.redirect("/")
Ejemplo n.º 18
0
 def post(self, slug):
     comment = Comments.select().where(Comments.id == slug)
     if comment:
         comment = Comments.select().where(Comments.id == slug).get()
         user = self.current_user
         # Only allow the creator of the post access to edit
         if comment.user_id == user.id:
             comment.delete_instance(recursive=True, delete_nullable=True)
         return self.redirect("/post/" + str(comment.post_id))
     return self.redirect("/")
Ejemplo n.º 19
0
 def post(self, slug):
     comment = Comments.select().where(Comments.id == slug)
     if comment:
         comment = Comments.select().where(Comments.id == slug).get()
         loggedInUser = self.current_user
         # Only allow the creator of the post access to edit
         if comment.user_id == loggedInUser.id:
             commentNew = self.get_body_argument('comment')
             # Edit Comment
             Comments.update(comment=commentNew).where(
                 Comments.id == slug).execute()
             return self.redirect("/post/" + str(comment.post_id))
     return self.redirect("/")
Ejemplo n.º 20
0
def comment(request, id):
    if request.method == 'POST':
        link = request.POST['link']
        desc = request.POST['desc']
        ch = Challenge.objects.filter(pk = id).first()
        
        [link, valid] = validateLink(link)
        
        com = Comments(challenge = ch, link = link, desc = desc, valid_video = valid)
        com.save()
        
        return HttpResponseRedirect(reverse('challenge', args=[id]))

    return render(request, 'comment_form.html')
Ejemplo n.º 21
0
def curd_comments():
    req = json.loads(json.dumps(request.get_json()))
    if request.method == "GET" and admin_check(current_user.id):
        t_list = []
        for data in Comments.query.all():
            t_list.append(data.as_dict())
        return jsonify(t_list)
    elif not "cards_id" in req:
        return ("400: Bad Request")
    if (int(req["cards_id"]) in mem_access(
            current_user.id)["cards"]) or (admin_check(current_user.id)):
        if request.method == "POST":
            comments = Comments()
            comments.content = req["content"]
            comments.cards_id = req["cards_id"]
            comments.user_id = req["user_id"]
            db.session.add(comments)
        if request.method == "PUT":
            comments = Comments.query.filter_by(id=req["id"]).first()
            comments.content = req["content"]
            comments.cards_id = req["cards_id"]
            comments.user_id = req["user_id"]
        if request.method == "DELETE":
            Comments.query.filter_by(id=req["id"]).delete()
        db.session.commit()
    return ("Request Processed")
Ejemplo n.º 22
0
    def insert_comment(self,commentDesc,pID,bName,userid):
        maxcval = 0
        for index in database:
            if(database[index].get('userid')== userid):
                flag = True
                break
            else:
                flag = False

        for index in database:
            if(database[index].get('pin_id')== pID):
                print database[index].get('pin_id')
                flagpin = True
                break
            else:
                flagpin = False

        for index in database:
            if(database[index].get('commentid')>0):
                maxcval = database[index].get('commentid')
                print maxcval
            else:
                print "Not Found"

        for iad in database:
            if(database[iad].get('boardName') == bName):
                print iad
                flagcheck = True
                break
            else:
                flagcheck = False

        if(maxcval == None):
            maxcval = 0

        if(flag and flagcheck and flagpin):
                comment = Comments(commentDesc=commentDesc)
                comment['commentid'] = maxcval+1
                comment['cuserid'] = userid
                comment['cboard_name'] = bName
                comment['cpin_id'] = pID
                comment.store(database)
                URL = 'url'
                boards = str('/boards/')
                users = str('users/')
                pins = str('/pins/')
                comments = str('/comment/')
                return {"links":[{URL:users+str(userid)+boards+bName+pins+str(pID)+comments+str(comment['commentid']),"method":"PUT"},{URL:users+str(userid)+boards+bName+pins+str(pID)+comments+str(comment['commentid']),"method":"GET"},{URL:users+str(userid)+boards+bName+pins+str(pID)+comments+str(comment['commentid']),"method":"DELETE"}]}
        else:
                return '{"links":[]}'
Ejemplo n.º 23
0
    def post(self, module_id, campain_id):
        text = self.request.get("comment")
        user = users.get_current_user()

        comment = Comments(text=text.strip(),
                           userMail=user.email(),
                           userId=user.user_id(),
                           campanya=campain_id,
                           module=module_id)

        comment.put()
        time.sleep(0.1)
        return webapp2.redirect("/foro/" + str(module_id) + "/" +
                                str(campain_id))
Ejemplo n.º 24
0
    def addComment(self, schoolID, commentData):

        user = User.get_by_id(int(commentData["userID"]))

        comment = Comments(school_id=schoolID, text=commentData["text"], user=user)

        comment.put()

        # create a new up/downvote key in memcache
        key = "CommentUpvote.%i" % comment.key().id()
        memcache.add(key, 0)
        key = "CommentDownvote.%i" % comment.key().id()
        memcache.add(key, 0)

        return comment
Ejemplo n.º 25
0
def comment():
    new_comment = request.form.get('comment')
    question_id = request.form.get('question_id')
    answer = Comments(comment_content=new_comment)

    user_id = session.get('user_id')
    user = User.query.filter(User.id == user_id).first()
    answer.author = user
    question = Question.query.filter(Question.id == question_id).first()
    answer.question = question

    db.session.add(answer)
    db.session.commit()

    return redirect(url_for('detail', question_id=question_id))
Ejemplo n.º 26
0
def home(request):
    blog_posts = load_blog()
    results = []
    archieves = []
    for blog in blog_posts:
        body = blog.body
        new_list = [m.start() for m in re.finditer(r"<br />", body)]
        new_line = body.index('<br />')
        for item in new_list:
            if item >= 750:
                new_line = item
                break
        body = body[:new_line]
        pre_start_list = [m.start() for m in re.finditer(r"<pre ", body)]
        pre_end_list = [m.start() for m in re.finditer(r"</pre>", body)]
        if pre_start_list:
            if not pre_end_list:
                pre_end = [
                    m.start() for m in re.finditer(r"</pre>", blog.body)
                ][0]
                body = blog.body[:pre_end]
        archieves.append(blog.title)
        date = blog.day[:10]
        day = date[8:10]
        month = date[5:7]
        mnth = get_month(month)
        results.append({
            'day': day,
            'month': mnth,
            'body': body,
            'title': blog.title
        })
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            p = Comments(name=data['name'],
                         comment=data['comment'],
                         title=request.POST['post_title'])
            p.save()
    comments = Comments.objects.order_by("-id")
    return render(
        request, 'home.html', {
            'posts': results,
            'outline': archieves,
            'comments': comments,
            'form': CommentForm
        })
Ejemplo n.º 27
0
 def post(self, postID):
     if self.session.get("username"):
         commentForm = CommentForm(self.request.POST)
         user = db.GqlQuery("SELECT * FROM User WHERE username='******'"
                            % self.session.get("username"))
         userID = user.get().key().id()
         if commentForm.validate():
             newComment = Comments(content=commentForm.comment.data,
                                   authorID=int(userID),
                                   postID=int(postID))
             newComment.put()
             self.redirect("/post/%s" % postID)
         else:
             self.redirect("/")
     else:
         self.redirect("/")
Ejemplo n.º 28
0
 def post(self):
     id = self.request.get('id')
     comment = Comments.get_by_id(int(id))
     if comment:
         comment.key.delete()
     else:
         logging.error('Not found {}'.format(id))
Ejemplo n.º 29
0
    def get(self, paper_id):
        iden = int(paper_id)
        Paper = ndb.Key('Papers', iden).get()

        q = Comments.query(Comments.RefObjType == 'paper', Comments.RefObjID == paper_id).order(Comments.CommentCode)
        comments = q.fetch(99)

        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/feedback/display' )
        else:
              login = users.create_login_url('/feedback/display')

        template_values = {
            'Paper': Paper, 
            'Comments': comments,
			'iden': paper_id,
            'currentuser':currentuser, 
            'login':login, 
            'logout': logout
            }

        #TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates')
#        jinja_environment = \
#            jinja2.Environment(autoescape=False, loader=jinja2.FileSystemLoader(TEMPLATE_DIR))

        template = jinja_environment.get_template('FeedbackDisplay.html')
#        jinja_environment.filters['AccessOK'] = AccessOK
        self.response.out.write(template.render(template_values))
Ejemplo n.º 30
0
    def schoolData(self):

        # get all comments
        comments = Comments.gql("WHERE school_id = :1 AND visible = True", self.school.school_id)
        commentsList = []

        if comments:
            for c in comments:
                comment = {
                    "id": c.key().id(),
                    "text": c.text,
                    "reports": c.reports,
                    "user": {"name": c.user.name, "gender": c.user.gender},
                    "upvote": memcache.get("CommentUpvote.%i" % c.key().id()),
                    "downvote": memcache.get("CommentDownvote.%i" % c.key().id()),
                }
                commentsList.append(comment)

        upvote = memcache.get("SchoolUpvote." + self.school.school_id)
        downvote = memcache.get("SchoolDownvote." + self.school.school_id)

        if upvote == None:
            upvote = self.school.upvote
            memcache.add("SchoolUpvote." + self.school.school_id, upvote)

        if downvote == None:
            downvote = self.school.downvote
            memcache.add("SchoolDownvote." + self.school.school_id, downvote)

        schoolData = {"comments": commentsList, "upvote": upvote, "downvote": downvote}

        return schoolData
Ejemplo n.º 31
0
def add_comment_api():
    if 'username' not in session:
        return "Must be authenticated", Status.HTTP_BAD_FORBIDDEN

    current_user = session['username']

    image_id = request.form['image_id']
    comment = request.form['comment']

    if not image_id or not comment:
        return "Missing required parameter", Status.HTTP_BAD_REQUEST
    if not Image.query.filter(Image.id == image_id).first():
        return "Invalid image id", Status.HTTP_BAD_REQUEST

    if not Image.query.filter(Image.id == image_id).first(
    ).owner == session['username'] and not Viewable.query.filter(
            Viewable.image_id == image_id
            and Viewable.user_name == current_user).first():
        return "You do not have permissions for this image", Status.HTTP_BAD_UNAUTHORIZED

    # Now can comment
    db.session.add(
        Comments(parent_image=image_id,
                 author=current_user,
                 comment_string=comment))
    db.session.commit()

    return "Successfully added comment", Status.HTTP_OK_BASIC
def get_single_comment(id):
    with sqlite3.connect("./rare.db") as conn:
        conn.row_factory = sqlite3.Row
        db_cursor = conn.cursor()

        # Use a ? parameter to inject a variable's value
        # into the SQL statement.
        db_cursor.execute("""
        SELECT
            c.id,
            c.post_id,
            c.author_id,
            c.content,
            c.created_on
        FROM comments as c
        WHERE c.id = ?
        """, ( id, ))

        # Load the single result into memory
        data = db_cursor.fetchone()

        # Create an comment instance from the current row
        comment = Comments(data['id'], data['post_id'], data['author_id'], data['content'], data['created_on'])


        return json.dumps(comment.__dict__)
Ejemplo n.º 33
0
def index():
    from models import Articles, Comments
    from forms import ArticlesForm, CommentsForm

    if request.method == 'POST':
        print(request.form)
        us_form = ArticlesForm(request.form)

        if us_form.validate():
            post_art = Articles(**us_form.data)
            db.session.add(post_art)
            db.session.commit()

            return 'Article was created'
        else:
            us_form = CommentsForm(request.form)

            if us_form.validate():
                post_com = Comments(**us_form.data)
                db.session.add(post_com)
                db.session.commit()
                return 'Commit was created'
            else:
                raise Exception
    if request.method == 'GET':
        vie_posts = Articles.query.all()
        return render_template('home.txt', posts=vie_posts)
Ejemplo n.º 34
0
 def post(self):
     user = self.user
     username = str(self.user.auth_ids)
     username = username.split('\'')
     message = self.request.get('message')
     newComment = self.request.get('newComment')
     if (message):
         newPost = Post(msg=message, userid=user.key)
         newPost.put()
         self.redirect("/wall")
     else:
         uid = self.request.get('uid')
         if (newComment):
             postMural = ndb.Key(urlsafe=uid).get()
             postMural.comments.append(
                 Comments(msg=newComment,
                          user_name_lastname=user.name + " " +
                          user.last_name,
                          user_auth_ids=username[1]))
             postMural.put()
             self.redirect("/wall")
         else:
             if (uid):
                 postMural = ndb.Key(urlsafe=uid).get()
                 params = {}
                 params['params'] = postMural
                 params['user'] = user
                 self.render('wall.html', params)
Ejemplo n.º 35
0
    def post(self, task_id):
        if task_id is None:
            return {'message': 'Bad task id, you must be admin'}, 401
        user = User.current()
        if user is None:  # or user.role != 'admin':
            return {'message': 'Bad user, you must be admin'}, 401

        data = request.get_json()
        if data is not None:
            if 'message' in data:
                c = Comments(task_id=task_id,
                             inspector_id=user.id,
                             message=data['message'])
                db.session.add(c)
            else:
                tsk = Tasks.query.filter_by(task_id=task_id).first()

                if tsk is None:
                    return {'message': 'Bad task, you must be admin'}, 401
                inspect = json.loads(tsk.inspect) if tsk.inspect else {}
                if 'rating' in data:
                    inspect['rating'] = data['rating']
                if 'progress' in data:
                    inspect['progress'] = data['progress']
                if 'status' in data:
                    inspect['status'] = data['status']

                tsk.inspect = json.dumps(inspect)
                db.session.add(tsk)
        db.session.commit()
        return {'message': 'Task was updated successful'}
Ejemplo n.º 36
0
    def get(self):
        posts = []
        cookie_user = self.get_user_from_cookie()
        if cookie_user:
            loggedin_user = cookie_user
        else:
            loggedin_user = None

        posts = Post.query(Post.is_draft == False).order(-Post.created)
        all_users = User.query()
        likes = Likes.query()

        list_dict = []

        for p in posts:
            p_dict = {}
            for u in all_users:
                if p.user == u.key:
                    p_dict['p_id'] = p.key.id()
                    p_dict['p_title'] = p.title
                    p_dict['p_content'] = p.content
                    p_dict['p_created'] = p.created
                    p_dict['a_name'] = u.fullname
                    p_dict['a_key'] = u.key
                    p_dict['a_id'] = u.key.id()
            for l in likes:
                if l.post == p.key:
                    p_dict['like_count'] = l.like_count
            comment_count = Comments.query(Comments.post == p.key).count()
            p_dict['c_count'] = comment_count
            list_dict.append(p_dict)

        return self.render('home.html', user=loggedin_user,
                           list_dict=list_dict)
Ejemplo n.º 37
0
    def get(self, id_campanya):

        if users.is_current_user_admin():

            q = Comments.all()
            q.filter('campanya', id_campanya)

            listaEmail = []
            listaNumero = []

            x = 0

            for c in q:
                if c.userMail in listaEmail:
                    listaNumero[listaEmail.index(
                        c.userMail)] = listaNumero[listaEmail.index(
                            c.userMail)] + 1
                else:
                    listaEmail.insert(x, c.userMail)
                    listaNumero.insert(x, 1)
                    x = x + 1

            self.render_template(
                'grafico.html', {
                    "users": listaEmail,
                    "numeros": listaNumero,
                    "tam": len(listaEmail)
                })

        else:
            return webapp2.redirect('/')
Ejemplo n.º 38
0
def iepginput(d):
    a_title = Title(name=d['program-title'])
    b_waves = Waves(name=d['station'])
    c_station = Station(name=d['station-name'])
    d_comments = Comments(name=d['comment'])
    op = timeset(d, start)
    ed = timeset(d, end)
    sg1 = d['genre-1'] * 16 + d['subgenre-1']
    if d['genre-2'] == 0:
        x = Program(title=a_title,
                    program_id=d['program-id'],
                    waves=b_waves,
                    station=c_station,
                    start=op,
                    end=ed,
                    gen_1=d['genre-1'],
                    sgn_1=sg1,
                    comments=d_comments)
        x.save
    else:
        sg2 = d['genre-2'] * 16 + d['subgenre-2']
        x = Program(title=a_title,
                    program_id=d['program-id'],
                    waves=b_waves,
                    station=c_station,
                    start=op,
                    end=ed,
                    gen_1=d['genre-1'],
                    sgn_1=sg1,
                    gen_2=d['genre-2'],
                    sgn_2=sg2,
                    comments=d_comments)
        x.save
Ejemplo n.º 39
0
 def get(self):
     user = None
     posts = Post.all().order('-created')
     comments = Comments.all().order('-created')
     if (self.user):
         user = self.user
     self.render('blog.html', user=user, posts=posts, comments=comments)
Ejemplo n.º 40
0
def read_blog(id):
    user = checkUser()
    blogs = Blogs.query.filter_by(id = id).all()
    if len(blogs) == 0:
        blog = ''
    else:
        blog = blogs[0]
    commentResult = Comments.query.filter_by(blog_id= id).order_by(Comments.created_at.desc()).all()
    comments = []
    for c in commentResult:
        like = Likes.query.filter(and_(Likes.user_id.like(user.id),Likes.comment_id.like(c.id))).all()
        if len(like):
            c.canLike = True
        else:
            c.canLike = False
        comments.append(c)
    blog.htmlcontent = markdown2.markdown(blog.content)
    form = CommentForm()
    if request.method == 'GET':
        return render_template(
            "blog.html",
            blog = blog,
            user = user,
            comments = comments,
            base64=base64,
            form = form,
        )
    if request.method == 'POST':
        content = form.comment.data
        comment = Comments(id = str(uuid1()),blog_id = blog.id,blog_name = blog.name,user_id = user.id,user_name = user.name,user_image = user.image,content = content)
        db.session.add(comment)
        db.session.commit()
        return redirect('/blog/'+blog.id)
Ejemplo n.º 41
0
    def save_to_database(self):
        self._parse()
        for i in range(len(self.id)):
            try:
                comment = Comments(
                    id=int(self.id[i]),
                    username=self.username[i],
                    user_center=self.user_center[i],
                    vote=int(self.vote[i]),
                    star=self.star[i],
                    time=datetime.strptime(self.time[i], '%Y-%m-%d %H:%M:%S'),
                    content=self.content[i]
                )

                self.session.add(comment)
                self.session.commit()
                return 'finish'


            except pymysql.err.IntegrityError as e:
                print('数据重复,不做任何处理')

            except Exception as e:
                #数据添加错误,回滚
                self.session.rollback()

            finally:
                #关闭数据库连接
                self.session.close()
Ejemplo n.º 42
0
 def get(self):
     list = Comments.query().fetch(keys_only=True)
     total = 0
     for item in list:
         task = taskqueue.add(url='/remove', params={'id': item.id()})
         total += 1
     logging.info('Total {}'.format(total))
Ejemplo n.º 43
0
def putcomment(request, recurso):

	actividad = Actividad.objects.get(id = recurso)

	comentario =  Comentario(tituloactividad=actividad.titulo, comentario=request.POST['comentario'])
	comentario.save()

	try:
		usuario = Comments.objects.get(user=request.user.username, titulo =actividad.titulo)
	except:
		usuario = Comments(user=request.user.username, titulo =actividad.titulo)
		usuario.save()

	usuario.comments.add(comentario)
	usuario.save()

	return HttpResponseRedirect("/")
Ejemplo n.º 44
0
 def post(self, post_id):
     comment = self.request.get('comment')
     post = Post.get_by_id(int(post_id))
     # user_id = check_for_valid_cookie(self)
     cookie_user = self.get_user_from_cookie()
     if cookie_user:
         if comment:
             comment_obj = Comments(user=cookie_user.key,
                                    post=post.key,
                                    comment=comment)
             comment_obj.put()
             time.sleep(0.2)
             self.redirect('/blog/%s'% post_id)
         else:
             empty_comment = "You can't post an empty content!"
             self.redirect('/blog/%s?empty_comment=True'%post.key.id())
     else:
         cookie_error = 'You have to be logged in to comment!'
         self.render('login.html', cookie_error=cookie_error)
Ejemplo n.º 45
0
def post_detail(request, id, showComments=False):
    if not request.user.is_authenticated():
       	return HttpResponseRedirect('/reg/login/')
	#return HttpResponseRedirect('/reg/login/?next=/blog/post_list%s' % request.path)
    else:
	post=Post.objects.get(pk=id)
	comment=Comments.objects.filter(post=id)
	if request.method == 'POST':
	    comment = Comments(post=post)
	    comment.author= request.user
	    form = CommentForm(request.POST, instance=comment)
	    if form.is_valid():
		form.save()
		return HttpResponseRedirect(request.path)
	else:
	    form = CommentForm()
	    
	    t = loader.get_template('blog/post_detail.html') 
	    c = Context({'posts':post, 'comments':comment,'form' : form,'user':request.user})
	    return HttpResponse(t.render(c))
Ejemplo n.º 46
0
    def post(self, comment_id):
        iden = int(comment_id)
        Comment = ndb.Key('Comments', iden).get()

        RefObjID=self.request.get('RefObjID')
        q = Comments.query(Comments.RefObjType == 'paper', Comments.RefObjID == RefObjID).order(-Comments.CommentCode)
        comments = q.fetch(99)

        CommentCodeLen = len(Comment.CommentCode)
        commentCodeEndPos = CommentCodeLen
        CommentCodeMax = chr(ord('A') - 1)
        SubCommentCnt = 0
        for subcomment in comments:
            if subcomment.CommentCode[0:commentCodeEndPos] == Comment.CommentCode:
                if len(subcomment.CommentCode) == (CommentCodeLen+1):
                    SubCommentCnt = SubCommentCnt + 1
                    if subcomment.CommentCode[CommentCodeLen] > CommentCodeMax:
                        CommentCodeMax = subcomment.CommentCode[CommentCodeLen]

        if SubCommentCnt == 0:
            SubCommentCode = Comment.CommentCode + 'A'
        else:
            CommentCodeMax2 = chr(ord(CommentCodeMax) + 1)
            PartCommentCode = Comment.CommentCode[:CommentCodeLen]
            SubCommentCode = PartCommentCode + CommentCodeMax2

        RefObjID=self.request.get('RefObjID')
        CreatedBy = users.get_current_user()

        n = Comments(Title=self.request.get('Title'),
                RefObjType=self.request.get('RefObjType'),
                RefObjID=RefObjID,
                CommentCode=SubCommentCode,
                IndentClass=len(SubCommentCode),
                Text=self.request.get('Text'),
                Status='Published',
                CreatedBy=CreatedBy,
                StatusBy=CreatedBy)
        n.put()

        return self.redirect('/papers/display/' + RefObjID)
Ejemplo n.º 47
0
def posts(request):
    if request.method == 'POST':
        form = CommentForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            p = Comments(name=cd['name'], comment=cd['comment'], title=request.POST['post_title'])
            p.save()
            posts = Newblogposts.objects.order_by("-id")
            comments = Comments.objects.order_by("-id")
            comment_form = CommentForm()
            return render( request, 'posts.html', {'posts': posts, 'comments': comments, 'comment_form': comment_form})
        else:
            posts = Newblogposts.objects.order_by("-id")
            comments = Comments.objects.order_by("-id")
            comment_form = CommentForm()
            return render( request, 'posts.html', {'posts': posts, 'comments': comments, 'comment_form': comment_form})
    else:
        posts = Newblogposts.objects.order_by("-id")
        comments = Comments.objects.order_by("-id")
        comment_form = CommentForm()
        return render( request, 'posts.html', {'posts': posts, 'comments': comments, 'comment_form': comment_form})
Ejemplo n.º 48
0
def alojamiento(request,ident):
    if request.user.is_authenticated:
        try:
            usersel = UserSels.objects.get(user=request.user.username, alojamiento_id=ident)
        except UserSels.DoesNotExist:
            usersel = UserSels(user=request.user.username, date=datetime.datetime.now(), alojamiento_id=ident)
            usersel.save()
    if request.method == 'POST':
        comment = Comments(user=request.user.username, text=request.POST['comment'], date=datetime.datetime.now(), alojamiento_id=ident)
        comment.save()
    try:
        comment = Comments.objects.get(user=request.user.username, alojamiento_id=ident)
        can_comment = False
    except Comments.DoesNotExist:
        can_comment = True
    context = ({'home': request.get_host(),
                'request': request,
                'alojamiento': Alojamientos.objects.get(id=ident),
                'images': Images.objects.filter(alojamiento_id=ident),
                'can_comment': can_comment})
    return render(request,'alojamiento.html',context)
Ejemplo n.º 49
0
    def save_comment(request):
        try:
            cid = request.POST.get('cid')
            if cid:
                comment = Comments.objects.get(pk=cid)
                comment.text = request.POST.get('text')
                comment.save()
            else:
                comment = Comments(
                    student_id=request.POST['stid'],
                    bonus_class_id=request.POST['group'],
                    text=request.POST.get('text'),
                    add_date=datetime.datetime.now()
                )
                comment.save()

            return HttpResponse(json.dumps({'id': comment.id}))

        except Exception:
            from traceback import format_exc; print format_exc()
            return HttpResponseServerError('failed')
Ejemplo n.º 50
0
    def get(self):

        q = Comments.query().order(Comments.RefObjType, Comments.RefObjID, Comments.CommentCode)
        comments = q.fetch(99)
		
        logout = None
        login = None
        currentuser = users.get_current_user()
        if currentuser:
              logout = users.create_logout_url('/comments' )
        else:
              login = users.create_login_url('/comments')
        self.render_template('CommentList.html', {'Comments': comments, 'currentuser':currentuser, 'login':login, 'logout': logout})
Ejemplo n.º 51
0
def articles(request,p_id):
    a_list = Articles.objects.filter(deleted = False)
    count = len(a_list)
    if count > 5:
        b_list = a_list[:5]
    else:
        b_list = a_list
    c_list = []
    for k in a_list:
        c_list.append(k.tag)
    c_list = list(set(c_list))
    d_list = []
    for k in a_list:
        d_list.append(k.cdt)
    d_list = list(set(d_list))
    p = Articles.objects.get(id = p_id)
    p.text = markdown(p.text)
    e_list = Comments.objects.filter(articles = p)
    for k in e_list:
        k.text = k.text.replace('\n','</br>')
    errors = []
    if request.method == 'POST':
        if not request.POST.get('author',''):
            errors.append('Enter name!')
        if not request.POST.get('email','') or '@' not in request.POST['email']:
            errors.append('Enter email address!')
        if not request.POST.get('comment',''):
            errors.append('Enter your comments!')
        if not errors:
            new = Comments(articles = p,name = request.POST['author'],dt=datetime.now(),email = request.POST['email'],text=escape(request.POST['comment']),deleted = False)
            new.save()
            p.cn = p.cn+1
            p.save()
            errors.append('Success!')
            return render_to_response('articles.html',{'list':p,'b_list':b_list,'c_list':c_list,'d_list':d_list,'e_list':e_list,'errors':errors})
        return render_to_response('articles.html',{'list':p,'b_list':b_list,'c_list':c_list,'d_list':d_list,'e_list':e_list,'errors':errors,'name':request.POST['author'],'email':request.POST['email'],'comment':request.POST['comment']})
    else:
        return render_to_response('articles.html',{'list':p,'b_list':b_list,'c_list':c_list,'d_list':d_list,'e_list':e_list})
Ejemplo n.º 52
0
 def get(self, post_id, comment_id):
     cookie_user = self.get_user_from_cookie()
     if cookie_user:
         comment = Comments.get_by_id(int(comment_id))
         if comment:
             comment.key.delete()
             time.sleep(0.2)
             self.redirect('/blog/%s'% str(post_id))
         else:
             comment_error = "Sorry the comment doesn't exist!"
             self.redirect('/blog/%s' % post_id)
     else:
         cookie_error = 'You have to be logged in to delete a comment!'
         self.render('login.html', cookie_error=cookie_error)
Ejemplo n.º 53
0
    def post(self):
        cookie_user = self.get_user_from_cookie()

        if cookie_user:
            post_id = self.request.get('postID')
            comment_id = self.request.get('commentID')
            comment_str = self.request.get('comment_str')
            if post_id and comment_id and comment_str:
                commentObj = Comments.get_by_id(int(comment_id))
                if commentObj:
                    commentObj.comment = comment_str
                    commentObj.put()
                    time.sleep(0.2)
                    commentObj = Comments.get_by_id(int(comment_id))
                    self.write(json.dumps(({'comment_str' : commentObj.comment})))
                    # self.redirect('/blog/%s'%post_id)
                else:
                    self.error(404)
            else:
                self.error(404)
                return
        else:
            cookie_error = 'You have to be logged in to edit a comment!'
            self.render('login.html', cookie_error=cookie_error)
Ejemplo n.º 54
0
    def get(self):
        loggedin_user = self.get_user_from_cookie()
        all_users = User.query()
        posts = Post.query()
        comments = Comments.query().order(-Comments.comment_date)

        # for each_user in all_users:
        #     each_post = Post.query(Post.user == each_user.key).fetch()
        #     posts.append(each_post)

        # for post in posts:
        #     return self.write(post)

        # for each_user_from_db in ndb.gql('select * from User'):
        #     for post in ndb.gql('select * from Post where user=:1',each_user_from_db.key):
        #         all_users = each_user_from_db
        #         posts.append(post)

        from_zone = tz.tzutc()
        to_zone = tz.tzlocal()
        post = Post.get_by_id(5642556234792960)

        date_utc = post.created
        date_utc = date_utc.replace(tzinfo=from_zone)

        localtz = date_utc.astimezone(to_zone)

        self.write("Post created UTC : %s" % post.created)
        self.write("<br>")
        self.write("<br>")
        self.write("Post Local : %s" % localtz)

        return self.render('test.html',
                           user=loggedin_user,
                           all_users=all_users,
                           posts=posts,
                           comments=comments)
Ejemplo n.º 55
0
def get_comments(ref_id, next_id=None, limit=100):
    if next_id:
        return Comments.select('where ref_id=? and _id<? order by _id desc limit ?', ref_id, next_id, limit)
    return Comments.select('where ref_id=? order by _id desc limit ?', ref_id, limit)
Ejemplo n.º 56
0
 def get(self, comment_id):
     commentObj = Comments.get_by_id(int(comment_id))
     self.write(json.dumps(({'comment': commentObj.comment})))
Ejemplo n.º 57
0
    def get(self, post_id):
        # user_id = check_for_valid_cookie(self)
        # cookie_user = User.get_by_id(int(user_id))
        cookie_user = self.get_user_from_cookie()

        post = Post.get_by_id(int(post_id))
        if post:
            comments = Comments.query(Comments.post == post.key).order(-Comments.comment_date)
            likes = Likes.query(Likes.post == post.key).get()

            list_dict = []

            comment_count = comments.count()

            if likes:
                no_of_likes = likes.like_count
            else:
                no_of_likes = 0

            for c in comments:
                c_dict = {}
                if c.post == post.key:
                    c_dict['c_id'] = c.key.id()
                    c_dict['c_comment'] = c.comment
                    c_dict['c_date'] = c.comment_date
                    user = User.query(User.key == c.user).get()
                    c_dict['c_u_name'] = user.fullname
                    c_dict['c_u_key'] = user.key
                    c_dict['c_u_id'] = user.key.id()
                    list_dict.append(c_dict)
            if cookie_user:
                if not post:
                    self.error(404)
                    return
                if cookie_user.key == post.user:
                    self.render("blog.html",
                                post=post,
                                user=cookie_user,
                                comments=list_dict,
                                like_count=no_of_likes,
                                comment_count=comment_count,
                                is_author=True)
                else:
                    self.render("blog.html",
                                post=post,
                                user=cookie_user,
                                comments=list_dict,
                                like_count=no_of_likes,
                                comment_count=comment_count,
                                is_author=False)
            else:
                self.render("blog.html",
                            post=post,
                            user=None,
                            comments=list_dict,
                            like_count=no_of_likes,
                            comment_count=comment_count,
                            is_author=False)
        else:
            self.error(404)
            return
Ejemplo n.º 58
0
def post_page(request, postid):
    if request.is_ajax():
        if "add" in request.path:
            prayer = Prayer.objects.get(id=postid)
            userobj = User.objects.get(username=request.user)
            userobj.profile.saved_prayer.add(prayer)
            userobj.save()
            return HttpResponse(status=200)
        else:
            prayer = Prayer.objects.get(id=postid)
            prayer.prayerscore = int(prayer.prayerscore) + 1
            if request.user not in prayer.prayed_users.all():
                prayer.prayed_users.add(request.user)
            timestamp = prayer.timestamp.astimezone(timezone('US/Central'))
            timestampdt = datetime.datetime(timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second)
            prayer.hotness = hot(prayer.prayerscore, timestampdt)
            prayer.save()
            this_group = Groups.objects.get(groupname=prayer.group.groupname)
            this_group_name = this_group.groupname
            this_group.total_hotness = helper_func.calc_group_hotness(this_group)
            this_group.save()
            dt = datetime.datetime.now()
            dtclean = dt.strftime('%Y-%m-%d %H:%M:%S')  
            userobj = User.objects.get(username=request.user)
            prayedfor = PrayedFor(prayed_user=userobj, prayer=prayer, timestamp=dtclean)
            prayedfor.save()
            return HttpResponse(status=200)
    else:
        if request.method == "POST":
            form = CommentForm(request.POST)
            if form.is_valid():
                dt = datetime.datetime.now()
                dtclean = dt.strftime('%Y-%m-%d %H:%M:%S')
                prayer = Prayer.objects.get(id=postid)
                comment = Comments(prayer=prayer, body=request.POST['comment'], posted_on=dtclean, user=request.user)
                comment.save()
                return HttpResponseRedirect('')
        form = CommentForm()
        prayer = Prayer.objects.get(id=postid)
        comments = Comments.objects.filter(prayer=prayer).order_by("-posted_on")
        top_groups = helper_func.calc_top_groups()
        saved_groups = helper_func.find_saved_groups(request.user)
        date = datetime.datetime.now()
        userobj = User.objects.get(username=request.user)
        saved_prayers = userobj.profile.saved_prayer
        subject = prayer.subject
        timestamp = prayer.timestamp.astimezone(timezone('US/Central'))
        timestampdt = datetime.datetime(timestamp.year, timestamp.month, timestamp.day, timestamp.hour, timestamp.minute, timestamp.second)
        prayer_post = prayer.prayer
        this_group = Groups.objects.get(groupname=prayer.group.groupname)
        this_group_name = this_group.groupname
        prayer_score = prayer.prayerscore
        prayed = helper_func.has_prayed_today(userobj, prayer)
        return render_to_response('post_page.html', 
                                 {'prayerscore': prayer_score, 
                                  'subject': subject, 'timestamp': timestamp, 
                                    'prayer': prayer_post, 'prayerobj': prayer, 'userid': request.user, 'saved_prayers': saved_prayers,
                                    'path': request.get_full_path, 'id': postid,
                                    'top_groups': top_groups, 'saved_groups': saved_groups, 'this_group': this_group_name, 'prayed': prayed, 'form': form, 'comments': comments
                                    }, 
                                        context_instance=RequestContext(request)
                                   )
Ejemplo n.º 59
0
def eventDetail(request, pk):
    if request.is_ajax():
        action = request.POST['operation']
        event = Event.objects.get(id=request.POST['eventId'])
        response = ""
        if action == "SignUp":
            if event.users.count() < event.numberOfPlayers:
                event.users.add(request.user.player)
                event.save()
                response = 'OK'
            else:
                response = 'Error'
        elif action == "Unsign":
            event.users.remove(request.user.player)
            event.save()
            response = 'Boli ste odhlásený z tejto akcie'
        elif action == "Delete":
            event.delete()
            response = "Deleted"
        elif action == "NewComment":
            comment = request.POST['comment']
            coment = Comments(eventId=event, user=request.user.player, comment=comment, sent=datetime.datetime.now())
            coment.save()
            if request.user.player.photo._file == None:
                photo = '/media/templates_img/user.png'
            else:
                photo = "/media/uploads/image/players/" + request.user.player.photo._file

            response = '<div class="ed_comment">' \
                        '<div class="ed_commentPhotoDiv">' \
                            '<img class="ed_commentPhoto"' \
                                'src="' + photo + '">' \
                          '</img>' \
                        '</div>' \
                        '<div class="ed_commentContentDiv">' \
                           ' <div class="ed_ccTop">' \
                                '<div class="ccTopName">' + coment.user.user.username + '</div>' \
                                '<div  class="ccTopDate">' + coment.sent.strftime("%d.%m.%Y %H:%M") + '</div>' \
                            '</div>' \
                           ' <div class="ed_ccBottom">' \
                               '' + coment.comment + '' \
                            '</div>' \
                        '</div>' \
                    '</div>'
        else:
            response = "Error"

        return HttpResponse(response)
    else:
        context = {}

        event = Event.objects.get(id = pk)

        context['mapHeight'] = 300
        context['mapWidth'] = 600
        context['mapZoomLevel'] = 14

        naive = event.login_since.replace(tzinfo=None)
        difference = datetime.datetime.now() - naive
        if (difference.total_seconds() > 0):
            context['signAllowed'] = True
        else:
            context['signAllowed'] = False

        context['isAuthor'] = False
        context['isSigned'] = False

        if request.user.is_authenticated():
            context['authenticated'] = True
            user = request.user
            if event.author.id == user.id:
                context['isAuthor'] = True
            try:
                event.users.get(id=user.player.id)
                context['isSigned'] = True
            except:
                context['isSigned'] = False
        else:
            context['authenticated'] = False

        comments = []
        for comment in Comments.objects.all().filter(eventId=event.id).order_by('sent'):
            comments.append(comment)
            context['comments'] = comments

        context['event'] = event
        context['numberInc'] = event.users.count() + 1
        return render_to_response('event/detail.html', context, context_instance=RequestContext(request))