Example #1
0
def reset_password(request, key):
    if LostPassword.objects.count() == 0:
        return render_response(request, 'user/change_password.html', {
            'error': True,
            'invalid': True
        })

    lostpwd = LostPassword.objects.get(key=key)
    if lostpwd.is_expired():
        lostpwd.delete()
        return render_response(request, 'user/change_password.html', {
            'error': True,
            'expired': True
        })
    else:
        if request.method == 'POST':
            form = ResetPasswordForm(request.POST)
            if form.is_valid():
                u = User.objects.get(username=lostpwd.user.username)
                u.set_password(form.cleaned_data['password'])
                u.save()
                lostpwd.delete()
                return render_response(request,
                                       'user/change_password_done.html',
                                       {'login_url': LOGIN_URL})
            else:
                return render_response(request, 'user/change_password.html',
                                       {'form': form})
        else:
            form = ResetPasswordForm()
            return render_response(request, 'user/change_password.html',
                                   {'form': form})
Example #2
0
def create_shopprofile(request):
    if request.user.shopprofile_set.count() > 0:
        return HttpResponse("Zaten profiliniz var")
    if request.method == 'POST':
        form = ShopProfileForm(request.POST.copy())
        if form.is_valid():
            shopProfile = ShopProfile(
                    user = request.user,
                    tcno = form.cleaned_data["tcno"],
                    phone = form.cleaned_data["phone"],
                    cellphone = form.cleaned_data["cellphone"],
                    address = form.cleaned_data["address"],
                    postcode = form.cleaned_data["postcode"],
                    town = form.cleaned_data["town"],
                    city = form.cleaned_data["city"],
                    billing_firstname = form.cleaned_data["billing_firstname"],
                    billing_lastname = form.cleaned_data["billing_lastname"],
                    billing_address = form.cleaned_data["billing_address"],
                    billing_postcode = form.cleaned_data["billing_postcode"],
                    billing_town = form.cleaned_data["billing_town"],
                    billing_city = form.cleaned_data["billing_city"],
                    billing_office = form.cleaned_data["billing_office"],
                    billing_no = form.cleaned_data["billing_no"],
                    )
            shopProfile.save()
            return render_response(request, "shopprofile/shopprofile_main.html", {"profile_updated":True,"form":form})
    else:
        form = ShopProfileForm()
    return render_response(request, "shopprofile/shopprofile_create.html", {"form":form})
Example #3
0
def edit_idea_add_image(request, idea_id):
    idea = get_object_or_404(Idea, pk=idea_id)
    image_form = ScreenShotForm()
    if request.POST:
        image_form_post = ScreenShotForm(
            request.POST,
            request.FILES,
        )
        if image_form_post.is_valid():
            try:
                image = image_form_post.save(commit=False)
                if image.image:
                    image.idea = idea
                    image.save()
            except:
                return render_response(request, 'beyin2/idea_errorpage.html',
                                       {'error': 'image cannot be saved'})
            return HttpResponseRedirect(
                reverse('oi.beyin2.views.edit_idea', args=(idea.id, )))
        return render_response(request, 'beyin2/idea_errorpage.html',
                               {'error': 'Form is not valid'})
    return render_response(request, 'beyin2/idea_edit_add_image.html', {
        'image_form': image_form,
        'idea': idea
    })
Example #4
0
def themeitem_add_desktopscreenshot(request):
    if request.method == "POST":
        form = DesktopScreenShotForm(request.POST.copy(), request.FILES)
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            item = form.save(commit=False)
            item.author = request.user
            item.submit = item.update = datetime.datetime.now()
            slug = slugify(replace_turkish(item.title))
            item.save()
            for tag in form.cleaned_data["tags"]:
                t=Tag.objects.get(name=tag)
                item.tags.add(t)
            item.slug = str(item.id) + "-" + slug
            item.save()

            #create thumbnail
            thumbnail = Image.open(item.image.path)
            thumbnail.thumbnail((150,200), Image.ANTIALIAS)
            file = ContentFile("")
            item.thumbnail.save(item.image.path, file, save=True)
            thumbnail.save(item.thumbnail.path)

            #TODO: Send e-mail to admins
            return render_response(request, "tema/themeitem_add_complete.html", locals())
    else:
        tags = [t.pk for t in Tag.objects.filter(name="masaüstü")]
        form = DesktopScreenShotForm(initial={"tags":tags})
    return render_response(request, "tema/themeitem_add_desktopscreenshot.html", locals())
Example #5
0
def create_contributednews(request):
    if request.method == "POST":
        form = ContributedNewsForm(request.POST.copy())
        if form.is_valid():
            news = News(
                title=form.cleaned_data["title"],
                slug=form.cleaned_data["slug"],
                image=form.cleaned_data["image"],
                sum=form.cleaned_data["sum"],
                text=form.cleaned_data["text"],
                update=datetime.datetime.now(),
                author=form.cleaned_data["author"],
                status=False,
            )
            news.save()

            # add tags
            for tag in form.cleaned_data["tags"]:
                t = Tag.objects.get(name=tag)
                news.tags.add(t)

            contributedNews = ContributedNews(
                news=news,
                contributor=request.user,
            )
            contributedNews.save()
            return HttpResponseRedirect("/editor/")
        else:
            return render_response(request, "editor/create.html", locals())
    else:
        form = ContributedNewsForm()
        return render_response(request, "editor/create.html", locals())
Example #6
0
def create_shopprofile(request):
    if request.user.shopprofile_set.count() > 0:
        return HttpResponse("Zaten profiliniz var")
    if request.method == 'POST':
        form = ShopProfileForm(request.POST.copy())
        if form.is_valid():
            shopProfile = ShopProfile(
                user=request.user,
                tcno=form.cleaned_data["tcno"],
                phone=form.cleaned_data["phone"],
                cellphone=form.cleaned_data["cellphone"],
                address=form.cleaned_data["address"],
                postcode=form.cleaned_data["postcode"],
                town=form.cleaned_data["town"],
                city=form.cleaned_data["city"],
                billing_firstname=form.cleaned_data["billing_firstname"],
                billing_lastname=form.cleaned_data["billing_lastname"],
                billing_address=form.cleaned_data["billing_address"],
                billing_postcode=form.cleaned_data["billing_postcode"],
                billing_town=form.cleaned_data["billing_town"],
                billing_city=form.cleaned_data["billing_city"],
                billing_office=form.cleaned_data["billing_office"],
                billing_no=form.cleaned_data["billing_no"],
            )
            shopProfile.save()
            return render_response(request,
                                   "shopprofile/shopprofile_main.html", {
                                       "profile_updated": True,
                                       "form": form
                                   })
    else:
        form = ShopProfileForm()
    return render_response(request, "shopprofile/shopprofile_create.html",
                           {"form": form})
Example #7
0
def create_contributednews(request):
    if request.method == "POST":
        form = ContributedNewsForm(request.POST.copy())
        if form.is_valid():
            news = News(
                    title = form.cleaned_data["title"],
                    slug = form.cleaned_data["slug"],
                    image = form.cleaned_data["image"],
                    sum = form.cleaned_data["sum"],
                    text = form.cleaned_data["text"],
                    update = datetime.datetime.now(),
                    author = form.cleaned_data["author"],
                    status = False,
                    )
            news.save()

            # add tags
            for tag in form.cleaned_data["tags"]:
                t=Tag.objects.get(name=tag)
                news.tags.add(t)

            contributedNews = ContributedNews(
                    news = news,
                    contributor = request.user,
                    )
            contributedNews.save()
            return HttpResponseRedirect("/editor/")
        else:
            return render_response(request, "editor/create.html", locals())
    else:
        form = ContributedNewsForm()
        return render_response(request, "editor/create.html", locals())
Example #8
0
def themeitem_add_desktopscreenshot(request):
    if request.method == "POST":
        form = DesktopScreenShotForm(request.POST.copy(), request.FILES)
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            item = form.save(commit=False)
            item.author = request.user
            item.submit = item.update = datetime.datetime.now()
            slug = slugify(replace_turkish(item.title))
            item.save()
            for tag in form.cleaned_data["tags"]:
                t = Tag.objects.get(name=tag)
                item.tags.add(t)
            item.slug = str(item.id) + "-" + slug
            item.save()

            #create thumbnail
            thumbnail = Image.open(item.image.path)
            thumbnail.thumbnail((150, 200), Image.ANTIALIAS)
            file = ContentFile("")
            item.thumbnail.save(item.image.path, file, save=True)
            thumbnail.save(item.thumbnail.path)

            #TODO: Send e-mail to admins
            return render_response(request, "tema/themeitem_add_complete.html",
                                   locals())
    else:
        tags = [t.pk for t in Tag.objects.filter(name="masaüstü")]
        form = DesktopScreenShotForm(initial={"tags": tags})
    return render_response(request,
                           "tema/themeitem_add_desktopscreenshot.html",
                           locals())
Example #9
0
def edit_idea(request, idea_id):
    idea = Idea.objects.get(pk=idea_id)
    if request.user == idea.submitter or request.user.has_perm("ideas.change_idea"):
        if request.method == 'POST':
            form = NewIdeaForm(request.POST)
            if form.is_valid():
                idea.tags.clear()
                for tag in form.cleaned_data['tags']:
                    t = Tag.objects.get(name=tag)
                    idea.tags.add(t)

                idea.title = form.cleaned_data['title']
                idea.description = form.cleaned_data['description']
                idea.category = form.cleaned_data['category']
                idea.related_to = form.cleaned_data['related_to']
                idea.forum_url = form.cleaned_data['forum_url']
                idea.bug_numbers = form.cleaned_data['bug_numbers']
                idea.save()

                #update topic
                topic = idea.topic
                topic.tags.clear()
                for tag in idea.tags.all():
                    topic.tags.add(tag)

                topic.title = idea.title
                topic.save()

                post = topic.post_set.order_by("created")[0]
                post_text = "<p>#" + str(idea.id) + " "
                post_text += "<a href=" + idea.get_absolute_url() + ">" + idea.title + "</a></p>"
                post_text += "<p>" + idea.description + "</p>"
                if form.cleaned_data['forum_url']:
                    post_text += "<p>İlgili Forum Linki<br /><a href='" + idea.forum_url + "'>" + idea.forum_url + "</a></p>"
                if idea.bug_numbers:
                    post_text += "<p>İlgili hatalar<br />"
                    for bug in idea.bug_numbers.replace(" ", "").split(","):
                        post_text += "<a href='http://bugs.pardus.org.tr/show_bug.cgi?id=" + bug + "'>" + bug + "</a> "

                post.text = post_text
                post.save()
                return HttpResponseRedirect(idea.get_absolute_url())
            else:
                return render_response(request, "idea_add_form.html", locals())
        else:
            form_data = {
                'title': idea.title,
                'description': idea.description,
                'category': idea.category_id,
                'related_to': idea.related_to_id,
                'forum_url': idea.forum_url,
                'bug_numbers': idea.bug_numbers,
                'tags': [tag.id for tag in idea.tags.all()],
                }
            form = NewIdeaForm(form_data)
            return render_response(request, "idea_add_form.html", locals())
    else:
        """ idea isn't yours error """
        return HttpResponseRedirect(idea.get_absolute_url())
Example #10
0
def howto_detail(request, slug):
    howto = get_object_or_404(HowTo, slug=slug)
    if howto.logo:
        related_howtos = howto.logo.howto_set.filter(status=True).exclude(id=howto.id)
    if not howto.status and not request.user.has_perm("st.change_howto"):
        return render_response(request, "404.html")
    form=PostForm()
    return render_response(request, 'howto/howto_detail.html', locals())
Example #11
0
def petition_sign(request):
    if request.method == 'POST':
        form = PetitionForm(request.POST)
        if form.is_valid():
            now = datetime.datetime.now()

            petitioner = Petitioner(
                firstname=form.cleaned_data['firstname'],
                lastname=form.cleaned_data['lastname'],
                city=form.cleaned_data['city'],
                job=form.cleaned_data['job'],
                email=form.cleaned_data['email'],
                homepage=form.cleaned_data['homepage'],
                signed=now,
                is_active=False,
                inform=form.cleaned_data['inform'],
            )

            # create key taken from profile/views.py
            salt = sha.new(str(random.random())).hexdigest()[:5]
            activation_key = sha.new(salt).hexdigest()
            petitioner.activation_key = activation_key
            petitioner.save()
            activation_link = "http://www.ozgurlukicin.com/petition/onay/%s/%s" % (
                petitioner.id, activation_key),

            email_subject = u"Ozgurlukicin.com OOXML'e hayır kampanyası"
            email_body = u"""Merhaba!
OOXML'e karsi yaptigimiz kampanyayi desteklediginiz icin tesekkur ederiz.
Lutfen desteginizi onaylamak icin asagida bulunan adresi ziyaret ederek
onaylama islemini yapiniz.

%s

Tesekkurler,
Ozgurlukicin.com"""

            email_to = form.cleaned_data['email']

            send_mail(email_subject,
                      email_body % activation_link,
                      DEFAULT_FROM_EMAIL, [email_to],
                      fail_silently=True)

            flatpage = FlatPage.objects.get(url="/ooxml/")
            notconfirmed = True

            return render_response(request, 'petition/sign_done.html',
                                   locals())
        else:
            return render_response(request, 'petition/sign.html', locals())
    else:
        petitioners = Petitioner.objects.order_by("-signed").filter(
            is_active=True)[:20]
        form = PetitionForm()
        flatpage = FlatPage.objects.get(url="/ooxml/")

        return render_response(request, 'petition/sign.html', locals())
Example #12
0
def report_abuse(request, item_id):
    themeitem = get_object_or_404(ThemeItem, id=item_id)

    try:
        ThemeAbuseReport.objects.get(themeitem=item_id)
        return render_response(request, "forum/forum_error.html",
                               {"message": "Bu ileti daha önce raporlanmış."})
    except ObjectDoesNotExist:
        if request.method == 'POST':
            form = AbuseForm(request.POST.copy())
            if form.is_valid():
                report = ThemeAbuseReport(themeitem=themeitem,
                                          submitter=request.user,
                                          reason=form.cleaned_data["reason"])
                report.save()

                email_subject = "Özgürlükİçin - Tema Şikayeti"
                email_body = """
%(topic)s başlıklı şikayet edildi.
İletiyi görmek için buraya tıklayın: %(link)s

İletinin içeriği: (<b>%(sender)s</b> tarafından yazılmış):
%(message)s
Şikayet metni buydu (%(reporter)s tarafından şikayet edilmiş):
%(reason)s
"""
                email_dict = {
                    "topic": themeitem.title,
                    "reporter": request.user.username,
                    "link": WEB_URL + themeitem.get_absolute_url(),
                    "message": striptags(render_bbcode(themeitem.text)),
                    "reason": striptags(report.reason),
                    "sender": themeitem.author.username,
                }
                send_mail(email_subject,
                          email_body % email_dict,
                          DEFAULT_FROM_EMAIL, [ABUSE_MAIL_LIST],
                          fail_silently=True)

                return render_response(
                    request, 'forum/forum_done.html', {
                        "message":
                        "İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz.",
                        "back": themeitem.get_absolute_url()
                    })
            else:
                return render_response(request, 'tema/report.html', {
                    "form": form,
                    "themeitem": themeitem
                })
        else:
            form = AbuseForm(auto_id=True)
            return render_response(request, 'tema/report.html', {
                "form": form,
                "themeitem": themeitem
            })
Example #13
0
def edit_idea(request, idea_id):
    idea = get_object_or_404(Idea, pk=idea_id)
    if idea.status:
        if idea.category:
            form = IdeaForm({'title': idea.title, 'description': idea.description, 'status': idea.status.id, 'category': idea.category.id, 'tags': [tag.id for tag in idea.tags.all()]})
        else:
            form = IdeaForm({'title': idea.title, 'description': idea.description, 'status': idea.status.id, 'tags': [tag.id for tag in idea.tags.all()]})
    else:
        if idea.category:
            form = IdeaForm({'title': idea.title, 'description': idea.description, 'category': idea.category.id, 'tags': [tag.id for tag in idea.tags.all()]})
        else:
            form = IdeaForm({'title': idea.title, 'description': idea.description, 'tags': [tag.id for tag in idea.tags.all()]})
    images = ScreenShot.objects.filter(is_hidden = False, idea = idea )
    if request.POST:
        form = IdeaForm(request.POST)
        if form.is_valid():
            idea.title = form.cleaned_data['title']
            idea.description = form.cleaned_data['description']
            if form.cleaned_data['status']:
                idea.status = form.cleaned_data['status']
            else:
                idea.status = Status()
            if form.cleaned_data['category']:
                idea.category = form.cleaned_data['category']
            else:
                idea.category = Category()
            idea.save()
            idea.topic.title = idea.title
            idea.topic.save()

            idea.tags.clear()
            idea.topic.tags.clear()
            for tag in form.cleaned_data['tags']:
                tag = Tag.objects.get(name=tag)
                idea.tags.add(tag)
                idea.topic.tags.add(tag)

            post_text = '<a href="'+  reverse('idea_detail', args =( idea.id,))
            post_text += '">#' + str(idea.id) + ": "
            post_text += idea.title + "</a>"
            post_text += "<p>" + idea.description + "</p>"
            for image in idea.screenshot_set.all():
                if image.is_hidden == False:
                    post_text += '<br /><img src="'+image.image.url+'" height="320" width"240" /><br />'

            post = idea.topic.post_set.all().order_by('created')[0]

            post.text = post_text
            post.save()

            return HttpResponseRedirect(reverse('oi.beyin2.views.main'))
        else:
            return render_response(request, 'beyin2/idea_errorpage.html')
    else:
        return render_response(request, 'beyin2/idea_edit.html', {'form':form, 'idea':idea,'images':images})
Example #14
0
def select_tags(request):
    form = TagsForm()
    if request.POST:
        form = TagsForm(request.POST)
        if form.is_valid:
            dummy_idea = form.save(commit=False)

            tags = form.cleaned_data['tags']

            idea_list = Idea.objects.all()

            similars_dict = {}

            if idea_list:
                for idea in idea_list:
                    if idea.is_hidden == False and idea.is_duplicate == False:
                        idea_tag_list = idea.tags.all()
                        counter = 0
                        for tag in tags:
                            if tag in idea_tag_list:
                                counter = counter + 1

                        for i in range(0, tags.count()):
                            if tags.count() - counter == i:
                                value = '<a href="' + reverse(
                                    'idea_detail',
                                    args=(idea.id, )) + '">' + idea.title
                                if idea.category:
                                    value += ' | ' + str(
                                        idea.vote_value / 10
                                    ) + ' Puan' + ' | ' + idea.category.name + '</a>'
                                else:
                                    value += ' | ' + str(
                                        idea.vote_value / 10
                                    ) + ' Puan' + ' | ' + 'Kategori belirtilmemiş' + '</a>'
                                value += '<br />' + idea.description[:
                                                                     140] + '...' + '<br /><br />'
                                similars_dict[str(i) + " " + value] = value
            else:
                return HttpResponse("IdeaYok")

            if similars_dict:
                output = ""
                liste = sorted(similars_dict.keys())
                for k in liste[:10]:
                    output += similars_dict[k]
                return HttpResponse(output)
            else:
                return HttpResponse("EslesmeYok")
        else:
            form = TagsForm()
            return render_response(request, 'beyin2/select_tags.html',
                                   {'form': form})
    return render_response(request, 'beyin2/select_tags.html', {'form': form})
Example #15
0
def themeitem_add_font(request):
    if request.method == "POST":
        form = FontForm(request.POST.copy(), request.FILES)
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            item = form.save(commit=False)
            item.author = request.user
            item.submit = item.update = datetime.datetime.now()
            slug = slugify(replace_turkish(item.title))
            item.save()
            for tag in form.cleaned_data["tags"]:
                t = Tag.objects.get(name=tag)
                item.tags.add(t)
            item.slug = str(item.id) + "-" + slug
            item.save()

            #create thumbnail
            twidth = 150
            theight = 100
            thumbnail = Image.new("RGBA", (twidth, theight))
            draw = ImageDraw.Draw(thumbnail)
            bigfont = ImageFont.truetype(item.font.path, 22)
            smallfont = ImageFont.truetype(item.font.path, 14)
            fill = (112, 112, 112)
            draw.text((5, 5), "Aa Ee Rr", font=bigfont, fill=fill)
            text_list = (
                (30, "Dag basini", u"Dağ başını"),
                (45, "duman almis,", u"duman almış,"),
                (60, "Gumus dere", u"Gümüş dere"),
                (75, "durmaz akar.", u"durmaz akar."),
            )
            for text in text_list:
                s = draw.textsize(text[1], font=smallfont)
                x = twidth - s[0] - 5
                if item.is_turkish:
                    draw.text((x, text[0]), text[2], font=smallfont, fill=fill)
                else:
                    draw.text((x, text[0]), text[1], font=smallfont, fill=fill)
            file = ContentFile("")
            item.thumbnail.save(item.font.path[:item.font.path.rfind(".")] +
                                ".png",
                                file,
                                save=True)
            thumbnail.save(item.thumbnail.path)

            #TODO: Send e-mail to admins
            return render_response(request, "tema/themeitem_add_complete.html",
                                   locals())
    else:
        tags = [t.pk for t in Tag.objects.filter(name="yazıtipi")]
        form = FontForm(initial={"tags": tags})
    return render_response(request, "tema/themeitem_add_font.html", locals())
Example #16
0
def lost_password(request):
    if request.method == 'POST':
        form = LostPasswordForm(request.POST)
        if form.is_valid():
            # generate new key and e-mail it to user
            random.seed()
            salt = sha.new(str(random.random())).hexdigest()[8:]
            key = sha.new(salt).hexdigest()

            u = User.objects.get(username=form.cleaned_data['username'])
            lostpwd = LostPassword(user=u)
            lostpwd.key = key
            lostpwd.key_expires = datetime.datetime.today(
            ) + datetime.timedelta(1)
            lostpwd.save()

            now = datetime.datetime.now()
            (date, hour) = now.isoformat()[:16].split("T")

            # mail it
            email_dict = {
                'date':
                date,
                'hour':
                hour,
                'ip':
                request.META['REMOTE_ADDR'],
                'user':
                form.cleaned_data['username'],
                'link':
                'http://www.ozgurlukicin.com/kullanici/kayip/degistir/%s' % key
            }

            email_subject = u"Özgürlükİçin.com Kullanıcı Parolası"
            email_body = u"""Merhaba!
%(date)s %(hour)s tarihinde %(ip)s IP adresli bilgisayardan kullanıcı parola sıfırlama isteği gönderildi. Lütfen parolanızı değiştirmek için aşağıdaki bağlantıyı 24 saat içerisinde ziyaret edin.

%(link)s"""
            email_to = form.cleaned_data['email']

            send_mail(email_subject,
                      email_body % email_dict,
                      DEFAULT_FROM_EMAIL, [email_to],
                      fail_silently=True)
            return render_response(request, 'user/lostpassword_done.html')
        else:
            return render_response(request, 'user/lostpassword.html',
                                   {'form': form})
    else:
        form = LostPasswordForm()
        return render_response(request, 'user/lostpassword.html',
                               {'form': form})
Example #17
0
def report_abuse(request, post_id):
    post = get_object_or_404(Post, pk=post_id, hidden=False)
    if post.topic.locked:
        return render_response(
            request, "forum/forum_error.html",
            {"message": "Bu konu kilitlenmiş olduğu için raporlanamaz."})

    try:
        AbuseReport.objects.get(post=post_id)
        return render_response(request, "forum/forum_error.html",
                               {"message": "Bu ileti daha önce raporlanmış."})
    except ObjectDoesNotExist:
        if request.method == 'POST':
            form = AbuseForm(request.POST.copy())
            if form.is_valid():
                report = AbuseReport(post=post,
                                     submitter=request.user,
                                     reason=form.cleaned_data["reason"])
                report.save()
                # now send mail to staff
                email_subject = "Özgürlükİçin Forum - İleti Şikayeti"
                email_body = """
%(topic)s başlıklı konudaki bir ileti şikayet edildi.
İletiyi forumda görmek için buraya tıklayın: %(link)s

İletinin içeriği buydu (%(sender)s tarafından yazılmış):
%(message)s
Şikayet metni buydu (%(reporter)s tarafından şikayet edilmiş):
%(reason)s
"""
                email_dict = {
                    "topic": post.topic.title,
                    "reporter": request.user.username,
                    "link": WEB_URL + post.get_absolute_url(),
                    "message": striptags(render_bbcode(post.text)),
                    "reason": striptags(report.reason),
                    "sender": post.author.username,
                }
                send_mail(email_subject,
                          email_body % email_dict,
                          DEFAULT_FROM_EMAIL, [ABUSE_MAIL_LIST],
                          fail_silently=True)
                return render_response(
                    request, 'forum/forum_done.html', {
                        "message":
                        "İleti şikayetiniz ilgililere ulaştırılmıştır. Teşekkür Ederiz.",
                        "back": post.get_absolute_url()
                    })
        else:
            form = AbuseForm(auto_id=True)

        return render_response(request, "forum/report.html", locals())
Example #18
0
def petition_sign(request):
    if request.method == "POST":
        form = PetitionForm(request.POST)
        if form.is_valid():
            now = datetime.datetime.now()

            petitioner = Petitioner(
                firstname=form.cleaned_data["firstname"],
                lastname=form.cleaned_data["lastname"],
                city=form.cleaned_data["city"],
                job=form.cleaned_data["job"],
                email=form.cleaned_data["email"],
                homepage=form.cleaned_data["homepage"],
                signed=now,
                is_active=False,
                inform=form.cleaned_data["inform"],
            )

            # create key taken from profile/views.py
            salt = sha.new(str(random.random())).hexdigest()[:5]
            activation_key = sha.new(salt).hexdigest()
            petitioner.activation_key = activation_key
            petitioner.save()
            activation_link = ("http://www.ozgurlukicin.com/petition/onay/%s/%s" % (petitioner.id, activation_key),)

            email_subject = u"Ozgurlukicin.com OOXML'e hayır kampanyası"
            email_body = u"""Merhaba!
OOXML'e karsi yaptigimiz kampanyayi desteklediginiz icin tesekkur ederiz.
Lutfen desteginizi onaylamak icin asagida bulunan adresi ziyaret ederek
onaylama islemini yapiniz.

%s

Tesekkurler,
Ozgurlukicin.com"""

            email_to = form.cleaned_data["email"]

            send_mail(email_subject, email_body % activation_link, DEFAULT_FROM_EMAIL, [email_to], fail_silently=True)

            flatpage = FlatPage.objects.get(url="/ooxml/")
            notconfirmed = True

            return render_response(request, "petition/sign_done.html", locals())
        else:
            return render_response(request, "petition/sign.html", locals())
    else:
        petitioners = Petitioner.objects.order_by("-signed").filter(is_active=True)[:20]
        form = PetitionForm()
        flatpage = FlatPage.objects.get(url="/ooxml/")

        return render_response(request, "petition/sign.html", locals())
Example #19
0
def merge(request, forum_slug, topic_id):
    forum = get_object_or_404(Forum, slug=forum_slug)
    topic = get_object_or_404(Topic, pk=topic_id)

    if topic.locked:
        hata="Kilitli konularda bu tür işlemler yapılamaz!"
        return render_response(request, 'forum/merge.html', locals())

    if request.method == 'POST':
        form = MergeForm(request.POST.copy())

        if form.is_valid():
            topic2 = form.cleaned_data['topic2']

            if int(topic2)==topic.id:
                hata="Aynı konuyu mu merge edeceksiniz !"
                return render_response(request, 'forum/merge.html', locals())


            topic2_object=get_object_or_404(Topic, pk=int(topic2))

            posts_tomove=Post.objects.filter(topic=topic.id)
            for post in posts_tomove:
                post.topic = topic2_object
                post.save()

            #increase count
            topic2_object.posts += posts_tomove.count()
            #increase and decrease post counts in case of a merge to a different forum
            forum = topic.forum
            forum2 = topic2_object.forum
            forum.posts -= posts_tomove.count()
            forum.topics -= 1
            forum2.posts += posts_tomove.count()

            #TODO: Handle changing lastpost of a forum
            #save and delete
            forum.save()
            forum2.save()
            topic2_object.save()
            topic.delete()

            return HttpResponseRedirect(topic2_object.get_absolute_url())
        else:
            hata="Forum valid degil!"
            return render_response(request, 'forum/merge.html', locals())

    else:
        form = MergeForm(auto_id=True)

    return render_response(request, 'forum/merge.html', locals())
Example #20
0
def merge(request, forum_slug, topic_id):
    forum = get_object_or_404(Forum, slug=forum_slug)
    topic = get_object_or_404(Topic, pk=topic_id)

    if topic.locked:
        hata = "Kilitli konularda bu tür işlemler yapılamaz!"
        return render_response(request, 'forum/merge.html', locals())

    if request.method == 'POST':
        form = MergeForm(request.POST.copy())

        if form.is_valid():
            topic2 = form.cleaned_data['topic2']

            if int(topic2) == topic.id:
                hata = "Aynı konuyu mu merge edeceksiniz !"
                return render_response(request, 'forum/merge.html', locals())

            topic2_object = get_object_or_404(Topic, pk=int(topic2))

            posts_tomove = Post.objects.filter(topic=topic.id)
            for post in posts_tomove:
                post.topic = topic2_object
                post.save()

            #increase count
            topic2_object.posts += posts_tomove.count()
            #increase and decrease post counts in case of a merge to a different forum
            forum = topic.forum
            forum2 = topic2_object.forum
            forum.posts -= posts_tomove.count()
            forum.topics -= 1
            forum2.posts += posts_tomove.count()

            #TODO: Handle changing lastpost of a forum
            #save and delete
            forum.save()
            forum2.save()
            topic2_object.save()
            topic.delete()

            return HttpResponseRedirect(topic2_object.get_absolute_url())
        else:
            hata = "Forum valid degil!"
            return render_response(request, 'forum/merge.html', locals())

    else:
        form = MergeForm(auto_id=True)

    return render_response(request, 'forum/merge.html', locals())
Example #21
0
def idea_detail(request,idea_id):
    idea = get_object_or_404(Idea, pk = idea_id)
    if idea.is_hidden:
        return render_response(request,'beyin2/idea_errorpage.html',{'error':'Fikir bulunamadı',})
    pos_votes = Vote.objects.filter( vote = 'U', idea = idea).count()
    notr_votes = Vote.objects.filter( vote = 'N', idea = idea ).count()
    neg_votes = Vote.objects.filter( vote = 'D', idea = idea ).count()
    idea.vote_text =  "Arti:%s kararsiz:%s Eksi:%s" %(pos_votes, notr_votes, neg_votes )

    status_list = Status.objects.all()
    category_list = Category.objects.all()
    def_cate = get_object_or_404(Status, pk = DefaultCategory )
    idea.duplicate_list = Idea.objects.filter( duplicate = idea )
    return render_response(request,'beyin2/idea_detail.html',{'idea': idea, 'status_list':status_list, 'category_list': category_list,'come_from':'detail', 'default_category' : def_cate})
Example #22
0
def list_abuse(request):
    abuse_count = ThemeAbuseReport.objects.count()

    if request.method == 'POST':
        list = request.POST.getlist('abuse_list')
        for id in list:
            ThemeAbuseReport.objects.get(id=id).delete()
        return HttpResponseRedirect(request.path)
    else:
        if ThemeAbuseReport.objects.count() == 0:
            return render_response(request, 'tema/abuse_list.html', {'no_entry': True})
        else:
            abuse_list = ThemeAbuseReport.objects.all()
            return render_response(request, 'tema/abuse_list.html', {'abuse_list': abuse_list, "abuse_count":abuse_count})
Example #23
0
def new_topic(request, forum_slug):
    forum = get_object_or_404(Forum, slug=forum_slug)

    if forum.locked and not request.user.has_perm("forum.add_topic"):
        return render_response(
            request, "forum/forum_error.html", {
                "message":
                "Bu forumda yeni başlık açamazsınız. Lütfen kilitli olmayan bir forumda başlık açınız."
            })

    if request.method == 'POST':
        form = TopicForm(request.POST.copy())
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            topic = Topic(forum=forum, title=form.cleaned_data['title'])
            topic.save()

            # add tags
            for tag in form.cleaned_data['tags']:
                t = Tag.objects.get(name=tag)
                topic.tags.add(t)

            post = Post(topic=topic,
                        author=request.user,
                        text=form.cleaned_data['text'])

            post.save()

            # generate post url
            post_url = WEB_URL + topic.get_absolute_url()

            # send e-mail to mailing list. We really rock, yeah!
            # send_mail_with_header('%s' % topic.title,
            #                       '%s<br /><br /><a href="%s">%s</a>' % (post.text, post_url, post_url),
            #                       '%s <%s>' % (request.user.username, FORUM_FROM_EMAIL),
            #                       [FORUM_MESSAGE_LIST],
            #                       headers = {'Message-ID': topic.get_email_id()},
            #                       fail_silently = True
            #                       )

            return HttpResponseRedirect(post.get_absolute_url())
    else:
        form = TopicForm(auto_id=True)

    if request.user.has_perm("forum.can_change_abusereport"):
        abuse_count = AbuseReport.objects.count()

    return render_response(request, 'forum/new_topic.html', locals())
Example #24
0
def themeitem_add_font(request):
    if request.method == "POST":
        form = FontForm(request.POST.copy(), request.FILES)
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            item = form.save(commit=False)
            item.author = request.user
            item.submit = item.update = datetime.datetime.now()
            slug = slugify(replace_turkish(item.title))
            item.save()
            for tag in form.cleaned_data["tags"]:
                t=Tag.objects.get(name=tag)
                item.tags.add(t)
            item.slug = str(item.id) + "-" + slug
            item.save()

            #create thumbnail
            twidth = 150
            theight = 100
            thumbnail = Image.new("RGBA", (twidth, theight))
            draw = ImageDraw.Draw(thumbnail)
            bigfont = ImageFont.truetype(item.font.path, 22)
            smallfont = ImageFont.truetype(item.font.path, 14)
            fill = (112,112,112)
            draw.text((5, 5), "Aa Ee Rr", font=bigfont, fill=fill)
            text_list = (
                (30, "Dag basini", u"Dağ başını"),
                (45, "duman almis,", u"duman almış,"),
                (60, "Gumus dere", u"Gümüş dere"),
                (75, "durmaz akar.", u"durmaz akar."),
            )
            for text in text_list:
                s = draw.textsize(text[1], font=smallfont)
                x = twidth - s[0] - 5
                if item.is_turkish:
                    draw.text((x, text[0]), text[2], font=smallfont, fill=fill)
                else:
                    draw.text((x, text[0]), text[1], font=smallfont, fill=fill)
            file = ContentFile("")
            item.thumbnail.save(item.font.path[:item.font.path.rfind(".")]+".png", file, save=True)
            thumbnail.save(item.thumbnail.path)

            #TODO: Send e-mail to admins
            return render_response(request, "tema/themeitem_add_complete.html", locals())
    else:
        tags = [t.pk for t in Tag.objects.filter(name="yazıtipi")]
        form = FontForm(initial={"tags":tags})
    return render_response(request, "tema/themeitem_add_font.html", locals())
Example #25
0
def themeitem_change_desktopscreenshot(request, item_id):
    object = get_object_or_404(DesktopScreenshot, pk=item_id)
    if request.user == object.author or request.user.has_perm("can_change_themeitem"):
        if request.method == "POST":
            form = DesktopScreenShotForm(request.POST.copy(), request.FILES)
            flood, timeout = flood_control(request)
            if flood:
                render_response(request, "tema/message.html", {"type": "error", "message": "Lütfen %s saniye sonra tekrar deneyiniz." % timeout })

            if form.is_valid():
                object.title = form.cleaned_data["title"]
                object.license = form.cleaned_data["license"]
                object.text = form.cleaned_data["text"]
                object.origin_url = form.cleaned_data["origin_url"]
                object.update = datetime.datetime.now()
                object.image = form.cleaned_data["image"]

                #change slug
                slug = slugify(replace_turkish(object.title))
                object.slug = str(object.id) + "-" + slug

                object.save()

                #create thumbnail
                thumbnail = Image.open(object.image.path)
                thumbnail.thumbnail((150,200), Image.ANTIALIAS)
                file = ContentFile("")
                object.thumbnail.save(object.image.path, file, save=True)
                thumbnail.save(object.thumbnail.path)

                return HttpResponseRedirect(object.get_absolute_url())

            else:
                return render_response(request, "tema/themeitem_change.html", locals())
        else:
            default_data = {"title": object.title,
                            "license": object.license,
                            "text": object.text,
                            "tags": object.tags.all(),
                            "origin_url": object.origin_url,
                            "image": object.image,
                            }

            form = DesktopScreenShotForm(initial=default_data)

        return render_response(request, "tema/themeitem_change.html", locals())

    else:
        return render_response(request, "tema/message.html", {"type": "error", "message": "Bu işlemi yapmak için yetkiniz yok."})
Example #26
0
def themeitem_add_packagescreenshot(request):
    if request.method == "POST":
        form = PackageScreenshotForm(request.POST.copy(), request.FILES)
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            item = form.save(commit=False)
            item.author = request.user
            item.submit = item.update = datetime.datetime.now()
            slug = slugify(replace_turkish(item.title))

            #change image file name
            path, extension = '/'.join(item.image.name.split('/')
                                       [:-1]), item.image.name.split('.')[-1]
            item.image.name = "%s/%s.%s" % (path, item.title, extension)
            item.save()

            for tag in form.cleaned_data["tags"]:
                t = Tag.objects.get(name=tag)
                item.tags.add(t)

            item.slug = str(item.id) + "-" + slug
            item.save()

            #create thumbnail
            thumbnail = Image.open(item.image.path)
            thumbnail.thumbnail((150, 200), Image.ANTIALIAS)
            file = ContentFile("")
            item.thumbnail.save(item.image.path, file, save=True)
            thumbnail.save(item.thumbnail.path)

            #create thumbnail for package manager
            s_image = Image.open(item.image.path)
            s_image.thumbnail((270, 190), Image.ANTIALIAS)
            file = ContentFile("")
            item.s_image.save(item.image.path, file, save=True)
            s_image.save(item.s_image.path)

            #TODO: Send e-mail to admins
            return render_response(request, "tema/themeitem_add_complete.html",
                                   locals())
    else:
        tags = [t.pk for t in Tag.objects.filter(name="paket görüntüsü")]
        form = PackageScreenshotForm(initial={"tags": tags})

    return render_response(request,
                           "tema/themeitem_add_packagescreenshot.html",
                           locals())
Example #27
0
def cdclient_cargo(request, id):
    cdClient = get_object_or_404(CdClient, id=id)
    if request.method == "POST":
        form = CargoForm(request.POST.copy())
        if form.is_valid():
            cargo = form.save(commit=False)
            cargo.cdclient = cdClient
            cargo.save()
            message = loader.get_template("shipit/sent_email.html").render(
                Context({
                    "cdClient": cdClient,
                    "cargo": cargo
                }))
            mail = EmailMessage(
                "Pardus DVD isteğiniz",
                message,
                "Özgürlükiçin <%s>" % DEFAULT_FROM_EMAIL,
                [DVD_MAIL_LIST, cdClient.email],
                headers={"Message-ID": "%s-%s" % (cdClient.id, cdClient.hash)})
            mail.content_subtype = "html"
            mail.send(fail_silently=True)
            cdClient.sent = True
            cdClient.save()

            return HttpResponseRedirect(cdClient.get_absoulte_url())
    else:
        form = CargoForm()
    return render_response(request, "shipit/cargo.html", locals())
Example #28
0
def promo(request,idea_id):
    idea = get_object_or_404(Idea, pk = idea_id)
    pos_votes = Vote.objects.filter( vote = 'U', idea = idea).count()
    notr_votes = Vote.objects.filter( vote = 'N', idea = idea ).count()
    neg_votes = Vote.objects.filter( vote = 'D', idea = idea ).count()
    vote_text =  "Arti:%s kararsiz:%s Eksi:%s" %(pos_votes, notr_votes, neg_votes )
    return render_response(request, 'beyin2/idea_promote.html', { 'title': idea.title, 'id':idea.id, 'vote_text':vote_text })
Example #29
0
def hide(request, forum_slug, topic_id, post_id=False):
    topic = get_object_or_404(Topic, pk=topic_id)

    if post_id:
        post = get_object_or_404(Post, pk=post_id)

        if post.topic.hidden:
            return render_response(request, "forum/forum_error.html", { "message":"Konu gizli olduğu için mesajı gösteremezsiniz." })
        if post.hidden:
            post.hidden = 0
        else:
            post.hidden = 1

        post.save()

        return HttpResponseRedirect(topic.get_absolute_url())
    else:
        if topic.hidden:
            topic.hidden = 0
            # we also want to hide the posts
            for post in topic.post_set.all():
                post.hidden = 0
                post.save()
        else:
            topic.hidden = 1
            for post in topic.post_set.all():
                post.hidden = 1
                post.save()

        topic.save()

        return HttpResponseRedirect(topic.forum.get_absolute_url())
Example #30
0
def hide(request, forum_slug, topic_id, post_id=False):
    topic = get_object_or_404(Topic, pk=topic_id)

    if post_id:
        post = get_object_or_404(Post, pk=post_id)

        if post.topic.hidden:
            return render_response(
                request, "forum/forum_error.html",
                {"message": "Konu gizli olduğu için mesajı gösteremezsiniz."})
        if post.hidden:
            post.hidden = 0
        else:
            post.hidden = 1

        post.save()

        return HttpResponseRedirect(topic.get_absolute_url())
    else:
        if topic.hidden:
            topic.hidden = 0
            # we also want to hide the posts
            for post in topic.post_set.all():
                post.hidden = 0
                post.save()
        else:
            topic.hidden = 1
            for post in topic.post_set.all():
                post.hidden = 1
                post.save()

        topic.save()

        return HttpResponseRedirect(topic.forum.get_absolute_url())
Example #31
0
def themeitem_delete(request, item_id):
    themeItem = get_object_or_404(ThemeItem, id=item_id)
    if request.method == "POST":
        themeItem.delete()
        return HttpResponseRedirect("/tema/")
    else:
        return render_response(request, "tema/themeitem_delete.html", locals())
Example #32
0
def buy(request):
    user = request.user
    shopProfile = get_object_or_404(ShopProfile, user=user)
    cart = get_object_or_404(Cart, user=user)
    initial = {
        "productcount": cart.items.count(),
        "name": user.first_name,
        "lastname": user.last_name,
        "email": user.email,
        "telephone": shopProfile.phone,
        "telephonegsm": shopProfile.cellphone,
        "address": shopProfile.address,
        "postcode": shopProfile.postcode,
        "ilce": shopProfile.town,
        "city": shopProfile.get_city_display(),
        "country": "Türkiye",
        "taxname": shopProfile.billing_firstname,
        "taxlastname": shopProfile.billing_lastname,
        "taxadress": shopProfile.billing_address,
        "taxpostcode": shopProfile.billing_postcode,
        "taxilce": shopProfile.billing_town,
        "taxcity": shopProfile.get_billing_city_display(),
        "taxcountry": "Türkiye",
        "taxvergidairesi": shopProfile.billing_office,
        "taxvergino": shopProfile.billing_no,
        "tckimlikno": shopProfile.tcno,
        }
    form = BuyForm(initial=initial)
    return render_response(request, "cart/buy.html", {"form": form, "cartItems": cart.items.all()})
Example #33
0
def cdclient_cargo(request, id):
    cdClient = get_object_or_404(CdClient, id=id)
    if request.method == "POST":
        form = CargoForm(request.POST.copy())
        if form.is_valid():
            cargo = form.save(commit=False)
            cargo.cdclient = cdClient
            cargo.save()
            message = loader.get_template("shipit/sent_email.html").render(Context({"cdClient":cdClient,"cargo":cargo}))
            mail = EmailMessage(
                "Pardus DVD isteğiniz",
                message,
                "Özgürlükiçin <%s>" % DEFAULT_FROM_EMAIL,
                [DVD_MAIL_LIST, cdClient.email],
                headers={"Message-ID":"%s-%s" % (cdClient.id, cdClient.hash)}
            )
            mail.content_subtype = "html"
            mail.send(fail_silently=True)
            cdClient.sent = True
            cdClient.save()

            return HttpResponseRedirect(cdClient.get_absoulte_url())
    else:
        form = CargoForm()
    return render_response(request, "shipit/cargo.html", locals())
Example #34
0
def home(request):
    news = News.objects.filter(status=True).order_by('-update')[:NEWS_IN_HOMEPAGE]
    packages = Package.objects.filter(status=True).order_by('-update')[:PACKAGES_IN_HOMEPAGE]
    games = Game.objects.filter(status=True).order_by('-update')[:GAMES_IN_HOMEPAGE]
    howtos = HowTo.objects.filter(status=True).order_by('-update')[:HOWTOS_IN_HOMEPAGE]
    #seminar = Seminar.objects.filter(status=True).order_by('start_date')
    return render_response(request, 'home.html', locals())
Example #35
0
def pastedtext_toggle_hidden(request, id):
    paste = get_object_or_404(PastedText, id=id)
    if request.method == "POST":
        paste.is_hidden = not paste.is_hidden
        paste.save()
        return HttpResponseRedirect(paste.get_absolute_url())
    return render_response(request, "paste/pastedtext_toggle.html", {"paste":paste})
Example #36
0
def themeitem_delete(request, item_id):
    themeItem = get_object_or_404(ThemeItem, id=item_id)
    if request.method == "POST":
        themeItem.delete()
        return HttpResponseRedirect("/tema/")
    else:
        return render_response(request, "tema/themeitem_delete.html", locals())
Example #37
0
def detail(request, idea_id):
    absolute_url = "/yenifikir"
    idea = get_object_or_404(Idea, pk=idea_id, is_hidden=False)
    user_can_change_idea = False
    if request.user.is_authenticated():
        if request.user.id == idea.submitter_id or request.user.has_perm("ideas.change_idea"):
            user_can_change_idea = True
        try:
            f = Favorite.objects.get(user=request.user, idea=idea)
            idea.is_favorited = True
        except ObjectDoesNotExist:
            idea.is_favorited = False
        try:
            v = Vote.objects.get(user=request.user.id, idea=idea.id)
            idea.user_vote = v.vote
        except ObjectDoesNotExist:
            pass

    idea.save()
    statusform = Status.objects.all()
    duplicates = Idea.objects.filter(duplicate=idea)
    duplicate_of = idea.duplicate
    bugs = idea.bug_numbers.replace(" ","").split(",")
    categories = Category.objects.order_by('name')
    page_title = "%d numaralı fikrin detayları" % idea.id
    return render_response(request, "idea_detail.html", locals())
Example #38
0
def buy(request):
    user = request.user
    shopProfile = get_object_or_404(ShopProfile, user=user)
    cart = get_object_or_404(Cart, user=user)
    initial = {
        "productcount": cart.items.count(),
        "name": user.first_name,
        "lastname": user.last_name,
        "email": user.email,
        "telephone": shopProfile.phone,
        "telephonegsm": shopProfile.cellphone,
        "address": shopProfile.address,
        "postcode": shopProfile.postcode,
        "ilce": shopProfile.town,
        "city": shopProfile.get_city_display(),
        "country": "Türkiye",
        "taxname": shopProfile.billing_firstname,
        "taxlastname": shopProfile.billing_lastname,
        "taxadress": shopProfile.billing_address,
        "taxpostcode": shopProfile.billing_postcode,
        "taxilce": shopProfile.billing_town,
        "taxcity": shopProfile.get_billing_city_display(),
        "taxcountry": "Türkiye",
        "taxvergidairesi": shopProfile.billing_office,
        "taxvergino": shopProfile.billing_no,
        "tckimlikno": shopProfile.tcno,
    }
    form = BuyForm(initial=initial)
    return render_response(request, "cart/buy.html", {
        "form": form,
        "cartItems": cart.items.all()
    })
Example #39
0
def get_product(request, category_slug, product_slug):
    # filter by product and category slug together
    # becuase a product can have the same name but can be in different categories.

    product = get_object_or_404(Product, slug__exact=product_slug, category__slug__exact=category_slug)

    return render_response(request, "product/product_info.html", {"product": product})
Example #40
0
def edit_idea_add_image(request,idea_id):
    idea = get_object_or_404(Idea, pk=idea_id)
    image_form = ScreenShotForm()
    if request.POST:
        image_form_post  = ScreenShotForm(request.POST, request.FILES,)
        if image_form_post.is_valid():
            try:
                image = image_form_post.save(commit = False)
                if image.image:
                    image.idea = idea
                    image.save()
            except:
                return render_response(request, 'beyin2/idea_errorpage.html',{'error': 'image cannot be saved'})
            return HttpResponseRedirect(reverse('oi.beyin2.views.edit_idea', args=(idea.id,)))
        return render_response(request, 'beyin2/idea_errorpage.html',{'error': 'Form is not valid'})
    return render_response(request, 'beyin2/idea_edit_add_image.html', {'image_form':image_form, 'idea':idea})
Example #41
0
def add_bug(request):
    if request.method == "POST":
        form = BugForm(request.POST.copy())
        flood, timeout = flood_control(request)

        if form.is_valid() and not flood:
            bug = Bug(
                title=form.cleaned_data["title"],
                submitter=request.user,
                description=form.cleaned_data["description"],
                priority=form.cleaned_data["priority"],
                assigned_to=BUG_USER,
            )
            bug.save()
            email_dict = {
                "bugId":
                bug.id,
                "bugTitle":
                bug.title,
                "link":
                bug.get_full_url(),
                "title":
                bug.title,
                "priority":
                bug.get_priority_display(),
                "submitter":
                "%s %s <%s>" % (bug.submitter.first_name,
                                bug.submitter.last_name, bug.submitter.email),
                "assigned_to":
                "%s %s <%s>" %
                (bug.assigned_to.first_name, bug.assigned_to.last_name,
                 bug.assigned_to.email),
                "description":
                bug.description,
            }
            email_subject = u"[Hata %(bugId)s] Yeni: %(bugTitle)s"
            email_body = u"""%(link)s
Başlık: %(title)s
Öncelik: %(priority)s
Bildiren: %(submitter)s
Atanan: %(assigned_to)s

%(description)s
"""
            mail_set = set()
            mail_set.add(BUG_MAILLIST)
            mail_set.add(bug.submitter.email)
            mail_set.add(bug.assigned_to.email)
            # send mails seperately
            for subscriber in mail_set:
                send_mail(email_subject % email_dict,
                          email_body % email_dict,
                          BUG_FROM_EMAIL, [subscriber],
                          fail_silently=True)
            return HttpResponseRedirect(bug.get_absolute_url())
    else:
        form = BugForm(auto_id=True)

    return render_response(request, 'bug/bug_add.html', locals())
Example #42
0
def petitioner_confirm(request, pid, key):
    petitioner = Petitioner.objects.get(id=pid)
    if petitioner.is_active:
        already_active = True

        return render_response(request, "petition/sign_done.html", locals())
    elif petitioner.activation_key == key:
        petitioner.is_active = True
        petitioner.signed = datetime.datetime.now()
        petitioner.save()
        activation_done = True

        return render_response(request, "petition/sign_done.html", locals())
    else:
        wrongkey = True

        return render_response(request, "petition/sign_done.html", locals())
Example #43
0
def themeitem_add(request):
    if request.method == "POST":
        form = ThemeTypeForm(request.POST.copy())
        if form.is_valid():
            return HttpResponseRedirect("/tema/ekle/" + form.cleaned_data["category"])
    else:
        form = ThemeTypeForm()
    return render_response(request, "tema/themeitem_add.html", locals())
Example #44
0
def themeitem_add_wallpaper(request):
    #TODO: add SVG support
    WallpaperFileFormSet = formset_factory(WallpaperFileForm)
    if request.method == "POST":
        form = WallpaperForm(request.POST.copy())
        fileforms = WallpaperFileFormSet(request.POST.copy(), request.FILES)
        flood, timeout = flood_control(request)

        if form.is_valid() and fileforms.is_valid() and not flood:
            item = form.save(commit=False)
            item.author = request.user
            item.submit = item.update = datetime.datetime.now()
            slug = slugify(replace_turkish(item.title))
            item.save()
            for tag in form.cleaned_data["tags"]:
                t = Tag.objects.get(name=tag)
                item.tags.add(t)
            item.slug = str(item.id) + "-" + slug
            item.save()
            for form in fileforms.forms:
                paper = form.save(commit=False)
                paper.title = "%dx%d" % (paper.image.width, paper.image.height)
                paper.save()
                item.title = item.title.replace(paper.title, "")
                item.save()
                if form.cleaned_data["create_smaller_wallpapers"]:
                    item.create_smaller_wallpapers(paper)
                item.papers.add(paper)

            #create thumbnail from first paper
            firstpaper = item.papers.all()[0]
            thumbnail = Image.open(firstpaper.image.path)
            thumbnail.thumbnail((150, 200), Image.ANTIALIAS)
            file = ContentFile("")
            item.thumbnail.save(firstpaper.image.path, file, save=True)
            thumbnail.save(item.thumbnail.path)

            #TODO: Send e-mail to admins
            return render_response(request, "tema/themeitem_add_complete.html",
                                   locals())
    else:
        tags = [t.pk for t in Tag.objects.filter(name="duvar kağıdı")]
        form = WallpaperForm(initial={"tags": tags})
        fileforms = WallpaperFileFormSet()
    return render_response(request, "tema/themeitem_add_wallpaper.html",
                           locals())
Example #45
0
def petitioner_confirm(request, pid, key):
    petitioner = Petitioner.objects.get(id=pid)
    if petitioner.is_active:
        already_active = True

        return render_response(request, 'petition/sign_done.html', locals())
    elif petitioner.activation_key == key:
        petitioner.is_active = True
        petitioner.signed = datetime.datetime.now()
        petitioner.save()
        activation_done = True

        return render_response(request, 'petition/sign_done.html', locals())
    else:
        wrongkey = True

        return render_response(request, 'petition/sign_done.html', locals())
Example #46
0
def select_tags(request):
    form = TagsForm()
    if request.POST:
        form = TagsForm(request.POST)
        if form.is_valid:
            dummy_idea = form.save(commit = False)

            tags = form.cleaned_data['tags']

            idea_list = Idea.objects.all()

            similars_dict = {}

            if idea_list:
                for idea in idea_list:
                    if idea.is_hidden == False and idea.is_duplicate == False:
                        idea_tag_list = idea.tags.all()
                        counter = 0
                        for tag in tags:
                            if tag in idea_tag_list:
                                counter = counter + 1

                        for i in range(0, tags.count()):
                            if tags.count() - counter == i:
                                value = '<a href="' + reverse('idea_detail', args =( idea.id,)) + '">' + idea.title
                                if idea.category:
                                    value += ' | ' + str(idea.vote_value / 10) + ' Puan' + ' | ' + idea.category.name + '</a>'
                                else:
                                    value += ' | ' + str(idea.vote_value / 10) + ' Puan' + ' | ' + 'Kategori belirtilmemiş' + '</a>'
                                value += '<br />' + idea.description[:140] + '...' + '<br /><br />'
                                similars_dict[str(i) + " " + value] = value
            else:
                return HttpResponse("IdeaYok")

            if similars_dict:
                output = ""
                liste = sorted(similars_dict.keys())
                for k in liste[:10]:
                    output += similars_dict[k]
                return HttpResponse(output)
            else:
                return HttpResponse("EslesmeYok")
        else:
            form = TagsForm()
            return render_response(request, 'beyin2/select_tags.html', {'form': form})
    return render_response(request, 'beyin2/select_tags.html', {'form': form})
Example #47
0
def new_topic(request, forum_slug):
    forum = get_object_or_404(Forum, slug=forum_slug)

    if forum.locked and not request.user.has_perm("forum.add_topic"):
        return render_response(request, "forum/forum_error.html", { "message":"Bu forumda yeni başlık açamazsınız. Lütfen kilitli olmayan bir forumda başlık açınız." })

    if request.method == 'POST':
        form = TopicForm(request.POST.copy())
        flood,timeout = flood_control(request)

        if form.is_valid() and not flood:
            topic = Topic(forum=forum,
                          title=form.cleaned_data['title'])
            topic.save()

            # add tags
            for tag in form.cleaned_data['tags']:
                t=Tag.objects.get(name=tag)
                topic.tags.add(t)

            post = Post(topic=topic,
                        author=request.user,
                        text=form.cleaned_data['text'])

            post.save()

            # generate post url
            post_url = WEB_URL + topic.get_absolute_url()

            # send e-mail to mailing list. We really rock, yeah!
            # send_mail_with_header('%s' % topic.title,
            #                       '%s<br /><br /><a href="%s">%s</a>' % (post.text, post_url, post_url),
            #                       '%s <%s>' % (request.user.username, FORUM_FROM_EMAIL),
            #                       [FORUM_MESSAGE_LIST],
            #                       headers = {'Message-ID': topic.get_email_id()},
            #                       fail_silently = True
            #                       )

            return HttpResponseRedirect(post.get_absolute_url())
    else:
        form = TopicForm(auto_id=True)

    if request.user.has_perm("forum.can_change_abusereport"):
        abuse_count = AbuseReport.objects.count()

    return render_response(request, 'forum/new_topic.html', locals())
Example #48
0
def cdclient_list_cities(request):
    city_list = []
    for city in CITY_LIST:
        city_list.append((CdClient.objects.filter(sent=True, city=city[0]).count(), city[1]))
    city_list.sort()
    city_list.reverse()
    total = CdClient.objects.filter(sent=True).count()
    return render_response(request, "shipit/city_list.html", locals())
Example #49
0
def cdclient_list_sent(request, version_slug=None):
    if version_slug != None:
        version = get_object_or_404(PardusVersion, slug=version_slug)
        cdclient_list = CdClient.objects.filter(confirmed=True, sent=True, version=version)
    else:
        cdclient_list = CdClient.objects.filter(confirmed=True, sent=True)
    show_date = request.GET.has_key("date")
    return render_response(request, "shipit/clients_to_send.html", locals())
Example #50
0
def change_cdclient(request, id):
    cdClient = get_object_or_404(CdClient, id=id)
    if request.method == "POST":
        form = CdClientChangeForm(request.POST, instance=cdClient)
        if form.is_valid():
            form.save()
    else:
        form = CdClientChangeForm(instance=cdClient)
    return render_response(request, "shipit/change_cdclient.html", locals())
Example #51
0
def change_cdclient(request, id):
    cdClient = get_object_or_404(CdClient, id=id)
    if request.method == "POST":
        form = CdClientChangeForm(request.POST, instance=cdClient)
        if form.is_valid():
            form.save()
    else:
        form = CdClientChangeForm(instance=cdClient)
    return render_response(request, "shipit/change_cdclient.html", locals())
Example #52
0
def user_profile(request, name):
    info = get_object_or_404(User, username=name)
    has_sent_messages = info.post_set.filter(hidden=False).count() > 0
    apikey = googleMapsApiKey
    # beyin2 entities
    ideas = Idea.objects.filter(is_hidden=False, submitter=info)
    if not info.is_active:
        del info
    return render_response(request, 'user/profile.html', locals())
Example #53
0
def followed_topics(request):
    if request.method == 'POST':
        list = request.POST.getlist('topic_watch_list')
        if list:
            for id in list:
                # control if posted topic id belongs to user
                if not WatchList.objects.filter(topic__id=id).filter(user__username=request.user.username):
                    return HttpResponse('Konu bu kullanıcıya ait değil!')
                else:
                    WatchList.objects.filter(topic__id=id).filter(user__username=request.user.username).delete()
        # FIXME: Shouldn't be hardcoded.
        return HttpResponseRedirect('/kullanici/takip-edilen-konular/')
    else:
        if len(WatchList.objects.filter(user__username=request.user.username)) == 0:
            return render_response(request, 'user/followed_topics.html', {'no_entry': True})
        else:
            watch_list = WatchList.objects.filter(user__username=request.user.username)
            return render_response(request, 'user/followed_topics.html', {'watch_list': watch_list})
Example #54
0
def list_abuse(request):
    abuse_count = ThemeAbuseReport.objects.count()

    if request.method == 'POST':
        list = request.POST.getlist('abuse_list')
        for id in list:
            ThemeAbuseReport.objects.get(id=id).delete()
        return HttpResponseRedirect(request.path)
    else:
        if ThemeAbuseReport.objects.count() == 0:
            return render_response(request, 'tema/abuse_list.html',
                                   {'no_entry': True})
        else:
            abuse_list = ThemeAbuseReport.objects.all()
            return render_response(request, 'tema/abuse_list.html', {
                'abuse_list': abuse_list,
                "abuse_count": abuse_count
            })
Example #55
0
def themeitem_add(request):
    if request.method == "POST":
        form = ThemeTypeForm(request.POST.copy())
        if form.is_valid():
            return HttpResponseRedirect("/tema/ekle/" +
                                        form.cleaned_data["category"])
    else:
        form = ThemeTypeForm()
    return render_response(request, "tema/themeitem_add.html", locals())