parent
							
								
									5d28707e18
								
							
						
					
					
						commit
						10933dd48b
					
				@ -130,7 +130,8 @@ async fn main() -> std::io::Result<()> {
 | 
				
			|||||||
                            .service(
 | 
					                            .service(
 | 
				
			||||||
                                web::scope("/profile")
 | 
					                                web::scope("/profile")
 | 
				
			||||||
                                    .route("/{user_id}", web::get().to(views::view_profile)),
 | 
					                                    .route("/{user_id}", web::get().to(views::view_profile)),
 | 
				
			||||||
                            ),
 | 
					                            )
 | 
				
			||||||
 | 
					                            .route("/users/", web::get().to(views::index_users)),
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                    .service(
 | 
					                    .service(
 | 
				
			||||||
                        web::scope("/edit")
 | 
					                        web::scope("/edit")
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										21
									
								
								src/views.rs
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								src/views.rs
									
									
									
									
									
								
							@ -67,6 +67,27 @@ pub(crate) async fn index(
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/// Show the list of all available links if a user is authenticated
 | 
				
			||||||
 | 
					pub(crate) async fn index_users(
 | 
				
			||||||
 | 
					    tera: web::Data<Tera>,
 | 
				
			||||||
 | 
					    id: Identity,
 | 
				
			||||||
 | 
					) -> Result<HttpResponse, ServerError> {
 | 
				
			||||||
 | 
					    use super::schema::users::dsl::users;
 | 
				
			||||||
 | 
					    if let Some(id) = id.identity() {
 | 
				
			||||||
 | 
					        let connection = establish_connection()?;
 | 
				
			||||||
 | 
					        let all_users: Vec<User> = users.load(&connection)?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let mut data = Context::new();
 | 
				
			||||||
 | 
					        data.insert("name", &id);
 | 
				
			||||||
 | 
					        data.insert("title", "Benutzer der Freien Hochschule Stuttgart");
 | 
				
			||||||
 | 
					        data.insert("users", &all_users);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let rendered = tera.render("index_users.html", &data)?;
 | 
				
			||||||
 | 
					        Ok(HttpResponse::Ok().body(rendered))
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        Ok(redirect_builder("/admin/login/"))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
pub(crate) async fn view_link(
 | 
					pub(crate) async fn view_link(
 | 
				
			||||||
    tera: web::Data<Tera>,
 | 
					    tera: web::Data<Tera>,
 | 
				
			||||||
    id: Identity,
 | 
					    id: Identity,
 | 
				
			||||||
 | 
				
			|||||||
@ -14,6 +14,7 @@
 | 
				
			|||||||
            <li><a href="/admin/index/">Liste</a></li>
 | 
					            <li><a href="/admin/index/">Liste</a></li>
 | 
				
			||||||
            <li><a href="/admin/submit/">Hinzufügen</a></li>
 | 
					            <li><a href="/admin/submit/">Hinzufügen</a></li>
 | 
				
			||||||
            <li><a href="/admin/signup/">Einladen</a></li>
 | 
					            <li><a href="/admin/signup/">Einladen</a></li>
 | 
				
			||||||
 | 
					            <li><a href="/admin/view/users/">Benutzer</a></li>
 | 
				
			||||||
            <li style="float:right"><a href="/admin/logout/">Abmelden</a></li>
 | 
					            <li style="float:right"><a href="/admin/logout/">Abmelden</a></li>
 | 
				
			||||||
            <li style="float:right">
 | 
					            <li style="float:right">
 | 
				
			||||||
                <div class="willkommen">Herzlich willkommen {{ name }}</div>
 | 
					                <div class="willkommen">Herzlich willkommen {{ name }}</div>
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								templates/index_users.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								templates/index_users.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					{% extends "admin.html" %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% block head2 %}
 | 
				
			||||||
 | 
					<script src="/static/sorttable.js"></script>
 | 
				
			||||||
 | 
					{% endblock %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% block admin %}
 | 
				
			||||||
 | 
					<table class="sortable">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <th>
 | 
				
			||||||
 | 
					            Kürzel
 | 
				
			||||||
 | 
					        </th>
 | 
				
			||||||
 | 
					        <th>
 | 
				
			||||||
 | 
					            Ziellink
 | 
				
			||||||
 | 
					        </th>
 | 
				
			||||||
 | 
					        <th>
 | 
				
			||||||
 | 
					            Benutzername
 | 
				
			||||||
 | 
					        </th>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    {% for user in users %}
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <a href="/admin/view/profile/{{user.id}}"><span>{{user.id}}</span>
 | 
				
			||||||
 | 
					            </a>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <a href="/admin/view/profile/{{user.id}}">{{ user.email }}
 | 
				
			||||||
 | 
					            </a>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <a href="/admin/view/profile/{{user.id}}"><small>{{ user.username }}</small>
 | 
				
			||||||
 | 
					            </a>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    {% endfor %}
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					{% endblock %}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user