示例#1
0
    def post(self, request, *args, **kwargs):
        user = request.user
        pk = self.kwargs['pk']
        form = self.form_class(request.POST)
        repo = Repo.objects.get(user=user, main=True)
        if form.is_valid():
            title = request.POST['title']
            permalink = request.POST['permalink']
            content = request.POST['content']

            save_page_database(repo, title, permalink, content, pk)

            # Create header content for the markdown file
            head_content = page_header_content(title, permalink)

            # Convert the body content to markdown
            body_content = convert_content(content)

            # Write the content into files
            write_page_file(title.lower(), user, repo, head_content,
                            body_content)

            # Push the code online
            push_online(user, repo)
        return HttpResponseRedirect(reverse('page-update', args=[pk]))
示例#2
0
 def post(self, request, *args, **kwargs):
     form = self.form_class(request.POST)
     if form.is_valid():
         user = request.user
         repo = Repo.objects.get(user=user, main=True)
         theme = request.POST['theme']
         save_site_theme_data(repo, theme)
         create_config_file(user, repo)
         push_online(user, repo)
         return HttpResponseRedirect(reverse('sitetheme'))
示例#3
0
 def post(self, request, *args, **kwargs):
     form = self.form_class(request.POST)
     if form.is_valid():
         user = request.user
         title = request.POST['title']
         description = request.POST['description']
         avatar = request.POST['avatar']
         # save stuff to the database
         repo = Repo.objects.get(user=user, main=True)
         save_site_data(repo, title, description, avatar)
         create_config_file(user, repo)
         push_online(user, repo)
         return HttpResponseRedirect(reverse('home'))
示例#4
0
    def post(self, request, *args, **kwargs):
        form = self.form_class(request.POST)
        if form.is_valid():
            user = request.user
            repo = Repo.objects.get(user=user, main=True)
            dribbble = request.POST['dribbble']
            email = request.POST['email']
            facebook = request.POST['facebook']
            flickr = request.POST['flickr']
            github = request.POST['github']
            instagram = request.POST['instagram']
            linkedin = request.POST['linkedin']
            pinterest = request.POST['pinterest']
            rss = request.POST['rss']
            twitter = request.POST['twitter']
            stackoverflow = request.POST['stackoverflow']
            youtube = request.POST['youtube']
            googleplus = request.POST['googleplus']
            disqus = request.POST['disqus']
            google_analytics = request.POST['google_analytics']

            site_social_profile = SiteSocialProfile(
                user = user,
                dribbble = dribbble,
                email = email,
                facebook = facebook,
                flickr = flickr,
                github = github,
                instagram = instagram,
                linkedin = linkedin,
                pinterest = pinterest,
                rss = rss,
                twitter = twitter,
                stackoverflow = stackoverflow,
                youtube = youtube,
                googleplus = googleplus,
                disqus = disqus,
                google_analytics = google_analytics
            )
            site_social_profile.save()
            create_config_file(user, repo)
            push_online(user, repo)
            return HttpResponseRedirect(reverse('socialprofile'))
示例#5
0
    def post(self, request, *args, **kwargs):
        user = request.user
        pk = self.kwargs['pk']
        form = self.form_class(request.POST)
        repo = Repo.objects.get(user=user, main=True)
        if form.is_valid():
            author = request.POST['author']
            comments = request.POST['comments']
            date = request.POST['date']
            time = request.POST['time']
            layout = request.POST['layout']
            title = request.POST['title']
            content = request.POST['content']
            category = request.POST['category']

            # This is a turnaround... I don't know why it happened.
            # Checkbox produces 'on' as the result when selected.
            comments = assign_boolean_to_comments(comments)

            # save stuff to the post database
            post = save_post_database(repo, author, comments, date, time, layout, title, content, pk)

            # save stuff to the post_category database
            save_post_category_database(post, category, pk)

            file_name = create_file_name(date, title)

            # Create header content for the markdown file
            head_content = header_content(author, comments, date, time, layout, title)

            # Convert the body content to markdown
            body_content = convert_content(content)

            # Write the content into files
            write_file(file_name, head_content, body_content)

            # Move file to correct location
            move_file(file_name, user, repo)

            # send the changes online
            push_online(user, repo)
        return HttpResponseRedirect(reverse('home'))