-
-
Notifications
You must be signed in to change notification settings - Fork 28
Unitarias #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Kiro8888
wants to merge
36
commits into
Solvosoft:master
Choose a base branch
from
Kiro8888:unitarias
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Unitarias #69
Changes from 4 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
392f42a
Add button and categories
4dfb050
Changing the actions icon and adding preview
9906b28
change the comments
947c0a7
change the title of action and remove the option when touching the title
ee14c62
change the entry_list
bacf968
Beta, datatable in the Blog
7f54399
Add the datatable.
4a32b61
The datatable is loading the data.
783a2b3
Delete the author column
788dccb
Adding the data table with the change in the filter.
ec3a159
test de datatable
1f2ee77
add the serializer for author and categories
e53b16c
falta:
b78f04b
falta:
195575f
add the edit in the datatable, blog
8377f1f
add the update in the blog
f4b275d
change the fields, datatable
ad97945
Revert "change the fields, datatable"
5575f58
add the change in the viewset
08608d2
version con el actualizar en un modal
638fed4
Beta final.
14e1185
Blog funcional
0ed4427
bug de la ruta del action detail arreglado
6214b69
arrelgando bug: al seleccionar la fila se enrutaba en lugar de al sel…
2869d90
falta arreglar el problema con el actualizar
7a9f46e
beta de blog
bb58b70
codigo limpio
3bd31a5
arreglando problema con el title en el modal del eliminar
33cec10
creando mis pruebas unitarias
e50a935
validaciones de permisos compeltados
118c41f
permisos para ver detalles
54eb45c
Blog permission management
4fefffe
Add the test in the blog
5f95686
feature_image in the API
9b1578f
Add new API
a2c7d40
Add new api
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import base64 | ||
| from django.core.files.base import ContentFile | ||
| from django.utils.translation import gettext_lazy as _ | ||
| from rest_framework import serializers | ||
|
|
||
| class GTBase64FileField(serializers.Field): | ||
| def to_internal_value(self, data): | ||
|
|
||
| if not isinstance(data, list): | ||
| raise serializers.ValidationError(_("List was expected")) | ||
|
|
||
|
|
||
| if len(data) < 1: | ||
| raise serializers.ValidationError( | ||
| _("List must contain at least one element")) | ||
|
|
||
|
|
||
| file_info = data[0] | ||
|
|
||
|
|
||
| if not isinstance(file_info, dict) or 'name' not in file_info or 'value' not in file_info: | ||
| raise serializers.ValidationError( | ||
| _("Invalid structure. You need to provide {name: 'name of file', value: 'base64 string representation'}")) | ||
|
|
||
|
|
||
| file_name = file_info['name'] | ||
| file_value = file_info['value'] | ||
|
|
||
| try: | ||
|
|
||
| decoded_value = base64.b64decode(file_value) | ||
| except base64.binascii.Error: | ||
| raise serializers.ValidationError(_( | ||
| "The 'value' is not a valid base64 string")) | ||
|
|
||
| file_content = ContentFile(decoded_value, name=file_name) | ||
|
|
||
| return file_content | ||
|
|
||
| def to_representation(self, value): | ||
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,23 @@ | ||
| from django.forms import ModelForm | ||
| from django.test import TestCase | ||
| from django.utils.html import strip_tags # Agrega esta importación | ||
|
|
||
| from djgentelella.blog import models | ||
|
|
||
|
|
||
| class TestEntryEditing(TestCase): | ||
|
|
||
| def setUp(self): | ||
| self.entry = models.Entry.objects.create(title=u'Welcome!', | ||
| content='### Some Content', | ||
| is_published=False) | ||
| self.entry = models.Entry.objects.create( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to use factory-boy here. |
||
| title=u'Welcome!', | ||
| content='### Some Content', | ||
| is_published=False, | ||
| resume='This is a resume', | ||
| ) | ||
|
|
||
| class EntryForm(ModelForm): | ||
| class Meta: | ||
| model = models.Entry | ||
| fields = ['title', 'content', 'is_published'] | ||
| fields = ['title', 'content', 'is_published', 'resume'] | ||
|
|
||
| self.form_cls = EntryForm | ||
|
|
||
|
|
@@ -24,25 +27,25 @@ def test_form_editing(self): | |
| 'title': 'Last Post (Final)', | ||
| 'content': '### Goodbye!', | ||
| 'is_published': True, | ||
| 'resume': 'Last resume', | ||
| } | ||
|
|
||
| form = self.form_cls(update, instance=self.entry) | ||
|
|
||
| form.save() | ||
|
|
||
| actual = models.Entry.objects.get(pk=self.entry.pk) | ||
| self.assertEquals(actual.title, update['title']) | ||
| self.assertEquals(actual.content.raw, update['content']) | ||
| self.assertEqual(actual.title, update['title']) | ||
| self.assertEqual(actual.content.raw, update['content']) | ||
| self.assertIsNotNone(actual.published_timestamp) | ||
|
|
||
| self.assertEqual(strip_tags(actual.resume.rendered), update['resume']) # Comparar con rendered sin etiquetas HTML | ||
|
|
||
| class TestEntryCreation(TestCase): | ||
|
|
||
| def setUp(self): | ||
| class EntryForm(ModelForm): | ||
| class Meta: | ||
| model = models.Entry | ||
| fields = ['title', 'content', 'is_published'] | ||
| fields = ['title', 'content', 'is_published', 'resume'] | ||
|
|
||
| self.form_cls = EntryForm | ||
|
|
||
|
|
@@ -52,14 +55,14 @@ def test_form_create(self): | |
| 'title': 'Last Post (Final)', | ||
| 'content': '### Goodbye!', | ||
| 'is_published': False, | ||
| 'resume': 'Last resume', | ||
| } | ||
|
|
||
| form = self.form_cls(create) | ||
| print(form.errors) | ||
|
|
||
| form.save() | ||
|
|
||
| actual = models.Entry.objects.get(slug='last-post-final') | ||
| self.assertEquals(actual.title, create['title']) | ||
| self.assertEquals(actual.content.raw, create['content']) | ||
| self.assertEqual(actual.title, create['title']) | ||
| self.assertEqual(actual.content.raw, create['content']) | ||
| self.assertIsNone(actual.published_timestamp) | ||
| self.assertEqual(strip_tags(actual.resume.rendered), create['resume']) # Comparar con rendered sin etiquetas HTML | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fixtures in test you can use factory-boy it will allow you to easy create fixtures and deal with django model dependencies. https://factoryboy.readthedocs.io/en/stable/