These are chat archives for mirumee/saleor

12th
Jun 2018
Yunaz Gilang Ramadhan
@YunazGilang
Jun 12 2018 03:49
Hi, i want to create a custom product seeder. And in my customization i edited the product model, should i delet the migrations folder in product and restart with makemigrations once again?
Filip Kucharczyk
@Pacu2
Jun 12 2018 08:43
@NyanKiyoshi From what I've seen on the other sites, all of the 'delete' actions took place immediately, don't think that the flag is necessary, specially when action needs to be confirmed via email, on user's end.
Resetting token on email's change is a nice catch, I've missed it.
@YunazGilang Deleting product's migrations can interfere with all the others, as they relate with each other a lot. Not sure what's the purpose of deleting old migrations, but if you want to speed things up, you might try squashing them
Ray Besiga
@raybesiga_twitter
Jun 12 2018 08:59
Looks like the demo site is down http://demo.getsaleor.com/
Filip Kucharczyk
@Pacu2
Jun 12 2018 09:02
@raybesiga_twitter on it!
Ray Besiga
@raybesiga_twitter
Jun 12 2018 09:02
Thanks
Filip Kucharczyk
@Pacu2
Jun 12 2018 09:17
Back on the track, demo should be live now
Yunaz Gilang Ramadhan
@YunazGilang
Jun 12 2018 10:15
@Pacu2 Does squashing migration speed up in creating the table on schema.
Ah yeah, i have some issues here, i added new category for products, and define the new image directory for it. But when the program tried to open the image, it fails and raises errno 2 filenotfound. I ve checked the current working directory. And the path seems fine. Not sure how to fix this, any suggestion?
Patryk Zawadzki
@patrys
Jun 12 2018 10:22
keep in mind all paths are relative to MEDIA_ROOT
Ray Besiga
@raybesiga_twitter
Jun 12 2018 11:41
@Pacu2 Great!
Yunaz Gilang Ramadhan
@YunazGilang
Jun 12 2018 11:49
@patrys ah yes, thanks, i was misplaced the image in the wrong directory. now it works.
Yunaz Gilang Ramadhan
@YunazGilang
Jun 12 2018 11:55
but, wouldn't the function get_image in random_data.py make the duplicate image we want to the MEDIA_ROOT directory? I am a little bit confused
NyanKiyoshi
@NyanKiyoshi
Jun 12 2018 13:35
@Pacu2 despite being low, there is still a risk of CSRF over the user deletion without a flag and timeout

@elwoodxblues

Also, the staff users can perform this operation from the dashboard. More related tools are to be added soon, see this Github project for details

The link is wrong ;)

def account_delete_confirm(request, token):
    user = get_object_or_404(User, token=token)
    user.delete()
    return TemplateResponse(
        request, 'account/account_delete.html')
Otherwise, we could add a confirm button to post into the view
Patryk Zawadzki
@patrys
Jun 12 2018 13:40
do we allow accounts to be deleted using GET?
NyanKiyoshi
@NyanKiyoshi
Jun 12 2018 13:40
With the emailed token (generated at user creation, never invalidated)
Patryk Zawadzki
@patrys
Jun 12 2018 13:40
certain firewalls will trigger any links found in an email message to check for malware
there’s also risk of the browser itself doing a load in the background where it anticipates a click
NyanKiyoshi
@NyanKiyoshi
Jun 12 2018 13:50
Looks like there is an issue with migrations https://i.imgur.com/IEG8WmK.png
I think we should check if the user is logged in as well, and then to do the followed request
user = get_object_or_404(User, pk=request.user.pk, token=token)
NyanKiyoshi
@NyanKiyoshi
Jun 12 2018 15:08
Index: saleor/account/models.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- saleor/account/models.py    (revision 7e8e2b7b846d8f2b383c07abb292567da3d51e78)
+++ saleor/account/models.py    (date 1528815425000)
@@ -102,7 +102,7 @@
     addresses = models.ManyToManyField(
         Address, blank=True, related_name='user_addresses')
     is_staff = models.BooleanField(default=False)
-    token = models.UUIDField(default=get_token, editable=False)
+    token = models.UUIDField(default=get_token, editable=False, unique=True)
     is_active = models.BooleanField(default=True)
     note = models.TextField(null=True, blank=True)
     date_joined = models.DateTimeField(default=timezone.now, editable=False)
Index: saleor/account/migrations/0020_user_token.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- saleor/account/migrations/0020_user_token.py    (revision 7e8e2b7b846d8f2b383c07abb292567da3d51e78)
+++ saleor/account/migrations/0020_user_token.py    (date 1528816061000)
@@ -1,7 +1,15 @@
 # Generated by Django 2.0.3 on 2018-05-30 12:26

 from django.db import migrations, models
-import saleor.account.models
+
+from saleor.account.models import get_token
+
+
+def create_uuid(apps, schema_editor):
+    accounts = apps.get_model('account', 'User').objects.all()
+    for account in accounts:
+        account.token = get_token()
+        account.save()


 class Migration(migrations.Migration):
@@ -14,6 +22,15 @@
         migrations.AddField(
             model_name='user',
             name='token',
-            field=models.UUIDField(default=saleor.account.models.get_token, editable=False),
-        ),
+            field=models.UUIDField(blank=True, null=True, editable=False),
+        ),
+        migrations.RunPython(create_uuid),
+        migrations.AlterField(
+            model_name='user',
+            name='token',
+            field=models.UUIDField(
+                default=get_token,
+                blank=False, null=False,
+                editable=False, unique=True)
+        )
     ]
This would fix the migrations (cf. https://stackoverflow.com/questions/35281003/django-migration-with-uuid-field-generates-duplicated-values#44482407)
Patryk Zawadzki
@patrys
Jun 12 2018 15:15
yes, the migration should explicitly set the value for each existing row
NyanKiyoshi
@NyanKiyoshi
Jun 12 2018 15:16
Should we go to patch the affected migration file directly?
Patryk Zawadzki
@patrys
Jun 12 2018 15:19
honestly I’d create a new migration file as patching the existing migration won’t help anyone who already experiences the problem (as it’s already marked as applied)
NyanKiyoshi
@NyanKiyoshi
Jun 12 2018 15:20
So we would override every token?
Pete Dermott
@petedermott
Jun 12 2018 15:45
Hey everyone, I'm just getting started with Saleor and I'm pretty impressed! One quick thing though, why are there both categories and collections? and why can a collection not have subcategories / sub-collections?
Patryk Zawadzki
@patrys
Jun 12 2018 15:47
@NyanKiyoshi I think it’s safer than counting on everyone reverting a migration and then reapplying it
emihir0
@emihir0
Jun 12 2018 19:10
Hi. How hard would it be to implement the following problem domain in saelor as ecommerce solution? I want to make a B2B website where we will be selling two types of products - both of them will be shoes, but one will be sold as box (ie. unopened, e.g. 12 pairs from different sizes) and the other type is selling shoes by size
we have an inhouse built solution for it right now but our focus is on production/logistics and we don't want to spend so much time maintaining ecommerce... hence I'm looking for some solution where something like I mentioned is possible
emihir0
@emihir0
Jun 12 2018 19:16
I assume in saelor it would be possible by having 2 nests of variants (is nesting in saelor supported?), ie: product -> color -> size. Where size can be range(36, 47) but also different boxes (e.g. box of 12 pairs of 41) where the price will be overriden in thsi case.