As an admin I want to be able to create a custom use. As an user I want to see listed only posts in the current selected language. As an user I want to be able to switch languages between EN-DE
This commit is contained in:
		
					parent
					
						
							
								c1db3b99ee
							
						
					
				
			
			
				commit
				
					
						d4bdf65858
					
				
			
		
					 7 changed files with 49 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,20 @@
 | 
			
		|||
from django.contrib import admin
 | 
			
		||||
from .models import CustomUser
 | 
			
		||||
from django.contrib.auth.hashers import make_password
 | 
			
		||||
 | 
			
		||||
admin.site.register(CustomUser)
 | 
			
		||||
 | 
			
		||||
class CustomUserAdmin(admin.ModelAdmin):
 | 
			
		||||
    fields = ('password', 'user_permissions', 'email', 'is_admin')
 | 
			
		||||
 | 
			
		||||
    def save_model(self, request, obj, form, change):
 | 
			
		||||
        password = form.cleaned_data.get('password')
 | 
			
		||||
 | 
			
		||||
        if not change:
 | 
			
		||||
            obj.validation_slug = make_password(None)
 | 
			
		||||
 | 
			
		||||
        obj.set_password(password)
 | 
			
		||||
        obj.save()
 | 
			
		||||
        return obj
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
admin.site.register(CustomUser, CustomUserAdmin)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue