Exemplo n.º 1
0
    def create(self, request):
        attrs = self.flatten_dict(request.POST)
        try:
            name = attrs['name']
            slug = slugify(name)
            category = Category.objects.get(attrs['category'])
            
        except KeyError:
            return MANDATORY_PARAMETER_MISSING
        except Category.DoesNotExist:
            return MANDATORY_PARAMETER_MISSING
        
        url = attrs.get('url')
        pull_quote = attrs.get('pull_quote')
        short_description = attrs.get('short_description')
        description = attrs.get('description')
        start_date = attrs.get('start_date')
        end_date = attrs.get('end_date')
        user = request.user
#        skills = models.ManyToManyField('Skill')
        project = Project(name=name, slug=slug, category=category,
                            url="" if url is None else url,
                            pull_quote="" if pull_quote is None else pull_quote,
                            short_description="" if short_description is None else short_description,
                            description="" if description is None else description,
                            start_date= start_date,
                            end_date= end_date,
                            user=user)
        project.save()
        return project
Exemplo n.º 2
0
    def load_file_content_to_db(self, fp):
        """ Take a path to markdown file,
            convert it to json
            then add content to Project db table
        """
       
        new_fname = self.convert_markdown_file_to_json(fp)

        file_content = self.parse_json_file(new_fname)
        if file_content:                
            proj = Project(**file_content)
            proj.save()
Exemplo n.º 3
0
def addproject(request, personp):
    #notifications = NotificationsField.objects.filter(person__username__contains=personp)
    if request.method == 'GET':
        context = {
            'form': AddProject,
            #'notifications': notifications,
        }
        return render(request, 'addproject.html', context)
    else:
        form = AddProject(request.POST, request.FILES)
        if form.is_valid():
            sup = Project(
                title=form.cleaned_data['title'],
                description=form.cleaned_data['description'],
                technology=form.cleaned_data['technology'],
                person=request.user,
                main_image=form.cleaned_data['main_image'],
                source_code=form.cleaned_data['source_code'],
                img1=form.cleaned_data['img1'],
                img2=form.cleaned_data['img2'],
                img3=form.cleaned_data['img3'],
            )
            #g1 = Project()
            print(sup)
            sup.save()
            #yha bhari cheez ane wali h(notifications)
            User = get_user_model()
            val = FollowersField.objects.filter(
                person__username__contains=request.user.username)
            sending_person = NewFields.objects.filter(
                person__username__contains=request.user.username)[0]
            for v in val:
                user1 = User.objects.filter(username=v.followers)[0]
                #user1 = NewFields.objects.filter(person__username__contains=v.followers)[0]
                shi_dbba = NotificationsField(
                    person=user1,
                    sender=sending_person,
                    Pid=sup.id,
                    notifications=request.user.username +
                    " recently added a project")
                shi_dbba.save()
                print(shi_dbba.notifications)
            dbba = Project.objects.filter(person__username__contains=personp)
            info = NewFields.objects.filter(person__username__contains=personp)
            context = {
                'dbba': dbba,
                'info': info,
            }
            #return render(request,'portfolio.html',context)
            return redirect(reverse('portfolio'))
Exemplo n.º 4
0
    def test_saving_retrieving_projects(self):
        first_project = Project()
        first_project.name = "The first ever test project"
        first_project.save()

        second_project = Project()
        second_project.name = "The second test project"
        second_project.save()

        saved_projects = Project.objects.all()
        self.assertEqual(saved_projects.count(), 2)

        first_saved_project = saved_projects[0]
        second_saved_project = saved_projects[1]
        self.assertEqual(first_saved_project.name,
                         'The first ever test project')
        self.assertEqual(second_saved_project.name, 'The second test project')
Exemplo n.º 5
0
    def _enter_projects(self):
        with open('portfolio/data/projects-full.json', 'r') as f:
            data = json.load(f)

        for row in data:
            project = Project(title=row['title'],
                              description=row['description'],
                              live_link=row['live_link'],
                              source_code=row['source_code'],
                              blog_link=row['blog_link'])
            project.save()

            image_name = row['image']
            abs_path = os.path.join(BASE_DIR,
                                    "portfolio/data/screenshots/" + image_name)

            with open(abs_path, 'rb') as f:
                django_file = File(f)
                project.image.save(image_name, django_file)
Exemplo n.º 6
0
    def test_creating_and_retrieving_projects(self):
        first_project = Project()
        first_project.title = '1st project'
        first_project.description = '1st desc'
        first_project.save()

        second_project = Project()
        second_project.title = '2nd project'
        second_project.description = '2nd desc'
        second_project.save()

        projects = Project.objects.all()
        self.assertEqual(projects.count(), 2)

        first_saved_project = projects[0]
        self.assertEqual(first_saved_project.title, '1st project')
        self.assertEqual(first_saved_project.description, '1st desc')

        second_saved_project = projects[1]
        self.assertEqual(second_saved_project.title, '2nd project')
        self.assertEqual(second_saved_project.description, '2nd desc')
Exemplo n.º 7
0
    def run_from_argv(self, *args):

        languages = (
            'PHP',
            'MySQL',
            '(X)HTML',
            'CSS',
            'Python/Django',
            'JavaScript/jQuery',
        )

        # Build Technologies
        print "Adding languages..."
        for lang in languages:
            l = Language()
            l.name = lang
            l.save()

        today = datetime.date.today()
        start = today - datetime.timedelta(weeks=15)

        print "Adding projects..."
        for i in range(4):
            if i == 0:
                i = 1

            languages = Language.objects.get(pk=i)

            p = Project()
            p.begun = start
            p.completed = today
            p.title = "Project Number %s" % (i,)
            p.slug = "project-%s" % (i,)
            p.client = "Myself"
            p.description = "I did stuff on this project"
            p.save()
            p.languages.add(languages)
            p.save()
Exemplo n.º 8
0
 def test_cannot_save_empty_projects(self):
     project = Project(title='', description='', link='')
     with self.assertRaises(ValidationError):
         project.save()
         project.full_clean()
Exemplo n.º 9
0
ajax_skill = Skill(name="Ajax")
ajax_skill.save()

sparklines_dash_project = Project(
    title="Real-Time Sparklines Dashboard",
    description="A real-time dashboard for quickly visualizing tends in currency "
    "fluctuations for major currencies over the past month. Developed end-to-end "
    "to display metrics in real-time. Extracts metrics from the ECB currency "
    "API, transforms data using Python's Pandas, visualizes sparklines using "
    "d3. Served using nginx and gunicorn via the Flask micro-framework.",
    link="http://sparklines-dash.rowanv.com",
    thumbnail="/static/images/sparklines_dash.png",
    tag_name="sparklines_dash",
    code_link="https://github.com/rowanv/sparklines_dash",
)
sparklines_dash_project.save()
sparklines_dash_project.skills_list.add(
    python_skill, pandas_library_skill, flask_library_skill, java_script_skill, d3_library_skill, html_skill, css_skill
)

business_dash_project = Project(
    title="Real-Time Business Dashboard",
    description="  A dynamic dashboard for visualizing a movie rental company"
    "'s key business metrics. Developed end-to-end to display metrics in real-time."
    "Extracts metrics from a MySQL database, transforms data using Python, "
    "visualizes charts and graphs using d3. Served using nginx and gunicorn "
    "via the Flask micro-framework.",
    link="http://dash.rowanv.com",
    thumbnail="/static/images/business_dash.png",
    tag_name="business_dash",
    code_link="https://github.com/rowanv/giraffe_dash",